鱼C论坛

 找回密码
 立即注册
查看: 2411|回复: 2

[已解决]请教一下,怎么获取到验证码的请求地址呢

[复制链接]
发表于 2021-5-16 14:48:48 | 显示全部楼层 |阅读模式
10鱼币
请教各位,我想知道怎么爬到这个网站的验证码的地址

查询网站的url地址:
  1. http://cx.mem.gov.cn/
复制代码


验证码的地址后面跟着一个  data=一串数字
类似:
  1. http://cx.mem.gov.cn//GetImg?date=1621147452058
复制代码


怎么才能获取到这串数字呢

最好的有过程,感激不尽
最佳答案
2021-5-16 14:48:49
本帖最后由 suchocolate 于 2021-5-17 01:55 编辑

那串数字是当前系统秒数,用time.time()就能得到:
  1. import requests
  2. import time


  3. def main():
  4.     timestmp = str(time.time()).split('.')[0]
  5.     url = f'http://cx.mem.gov.cn//GetImg?date={timestmp}'
  6.     headers = {'user-agent': 'firefox'}
  7.     r = requests.get(url, headers=headers)
  8.     with open('test.jpg', 'wb') as f:
  9.         f.write(r.content)


  10. if __name__ == '__main__':
  11.     main()

复制代码

最佳答案

查看完整内容

那串数字是当前系统秒数,用time.time()就能得到:
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-16 14:48:49 | 显示全部楼层    本楼为最佳答案   
本帖最后由 suchocolate 于 2021-5-17 01:55 编辑

那串数字是当前系统秒数,用time.time()就能得到:
  1. import requests
  2. import time


  3. def main():
  4.     timestmp = str(time.time()).split('.')[0]
  5.     url = f'http://cx.mem.gov.cn//GetImg?date={timestmp}'
  6.     headers = {'user-agent': 'firefox'}
  7.     r = requests.get(url, headers=headers)
  8.     with open('test.jpg', 'wb') as f:
  9.         f.write(r.content)


  10. if __name__ == '__main__':
  11.     main()

复制代码
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

发表于 2021-5-17 09:17:58 | 显示全部楼层
看到这么长的会变的数字,肯定要往时间戳去想
小甲鱼最新课程 -> https://ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2025-6-23 17:39

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表