繁体   English   中英

如何请求 URL 每次更改一些数字?

[英]HOW TO request URL change some numbers every time?

例如,我有这个网址:

http://web.ca.com/y/d.ASP?id=1

我想每次都请求此 URL,并在每次我请求时更改 id。

如何通过 Python 做到这一点。

结果

http://web.ca.com/y/d.ASP?id=2

http://web.ca.com/y/d.ASP?id=3

http://web.ca.com/y/d.ASP?id=4

您可以使用requests

import requests

for x in range(0,10): # Here you define the amount of tries you're going to check    
   r = requests.get('http://web.ca.com/y/d.ASP?id={}'.format(x)) # this would be the loop value    
   print(r.status_code) # this would be the http response code

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM