【问题标题】:HOW TO request URL change some numbers every time?如何每次请求 URL 更改一些数字?
【发布时间】:2019-11-25 03:42:23
【问题描述】:

我有这个网址,例如:

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

【问题讨论】:

  • 您的问题能再具体一点吗?到目前为止,您尝试了什么,遇到了什么错误?
  • 也许用 PHP 改会更容易

标签: python function url


【解决方案1】:

你可以使用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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 2021-01-15
    • 1970-01-01
    • 1970-01-01
    • 2011-01-17
    • 1970-01-01
    相关资源
    最近更新 更多