无法打印输出
您好,我试图将网站作为其中的一部分刮擦,我写了第一个代码片段,以查看我可以打印URL,但我无法做到,我会在哪里做错?请帮忙
import requests
from time import sleep
def get_html(url):
response=requests.get(url)
if not response.ok:
print(f"Code: {response.status_code}, url:{url}")
return response.text
def main():
start = 1
url = 'https://www.vivo.com/in/support/queryProductInfosByClassifyId?classifyId={start}'
while True:
print(url)
if True:
start +=1
url = 'https://www.vivo.com/in/support/queryProductInfosByClassifyId?classifyId={start}'
else:
break
sleep(0.3)
if __name__ == ' __main__ ':
main()
Hello I am trying to scrape a website as a part of it I have written the first code snippet to see I can print the URLS but I am unable to do so, where am I going wrong? Please help
import requests
from time import sleep
def get_html(url):
response=requests.get(url)
if not response.ok:
print(f"Code: {response.status_code}, url:{url}")
return response.text
def main():
start = 1
url = 'https://www.vivo.com/in/support/queryProductInfosByClassifyId?classifyId={start}'
while True:
print(url)
if True:
start +=1
url = 'https://www.vivo.com/in/support/queryProductInfosByClassifyId?classifyId={start}'
else:
break
sleep(0.3)
if __name__ == ' __main__ ':
main()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论