用户名*
邮箱*
密码*
确认密码*
验证码* 点击图片更换验证码
找回密码
忘记密码了?输入你的注册邮箱,并点击重置,稍后,你将会收到一封密码重置邮件。
这网站真是奇葩,在post中填2460,一次就获取所有数据。
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Author: LoveNight # @Date: 2015-11-30 20:19:57 # @Last Modified by: LoveNight # @Last Modified time: 2015-11-30 21:00:23 import requests import csv from bs4 import BeautifulSoup as BS queryUrl = r'http://www.chinapesticide.gov.cn/myquery/queryselect' postData = { "nylb": "卫生杀虫剂", "pageSize": "2460", "pageNo": "1", "djzh":"", "cjmc":"", "sf":"", "zhl":"", "jx":"", "zwmc":"", "fzdx":"", "yxcf":"", "yxcf_en":"", "yxcfhl":"", "yxcf2":"", "yxcf2_en":"", "yxcf2hl":"", "yxcf3":"", "yxcf3_en":"", "yxcf3hl":"", "yxqs_start":"", "yxqs_end":"", "yxjz_start":"", "yxjz_end":"", } with open(r"F:\result.csv", 'w', encoding='gbk', newline='') as f: writer = csv.writer(f) html = requests.post(queryUrl, data=postData).text trs = BS(html, "html.parser").find("table", id="tab").find_all("tr") for tr in trs: row = [x.getText().strip() for x in tr.find_all("td")] writer.writerow(row)
昵称*
E-Mail*
回复内容*
回复 ( 1 )
这网站真是奇葩,在post中填2460,一次就获取所有数据。