【发布时间】:2014-09-30 22:38:42
【问题描述】:
我正在尝试从网站上抓取一些数据,但我无法让 POST 工作,就好像我没有给它输入数据(“appnote”)一样。
当我检查 POST 数据时,除了实际 Web 表单的 POST 被称为“URL 编码”并列出每个表单输入之外,它看起来相对相同,而我的被标记为“基于行的文本数据”。
这是我的代码:(appnote)和搜索(搜索)是我需要的最相关的部分
import requests
import cookielib
jar = cookielib.CookieJar()
url = 'http://www.vivotek.com/faq/'
headers = {'content-type': 'application/x-www-form-urlencoded'}
post_data = {#'__EVENTTARGET':'',
#'__EVENTARGUMENT':'',
'__LASTFOCUS':'',
'__VIEWSTATE':'',
'__VIEWSTATEGENERATOR':'',
'__VIEWSTATEENCRYPTED':'',
'__PREVIOUSPAGE':'',
'__EVENTVALIDATION':''
'ctl00$HeaderUc1$LanguageDDLUc1$ddlLanguage':'en',
'ctl00$ContentPlaceHolder1$CategoryDDLUc1$DropDownList1':'-1',
'ctl00$ContentPlaceHolder1$ProductDDLUc1$DropDownList1':'-1',
'ctl00$ContentPlaceHolder1$Content':'appnote',
'ctl00$ContentPlaceHolder1$Search':'Search'
}
response = requests.get(url, cookies=jar)
response = requests.post(url, cookies=jar, data=post_data, headers=headers)
print(response.text)
我在 Wireshark 中谈论的图片的链接:
我也使用 wget 进行了尝试,结果相同。
【问题讨论】:
标签: python web-scraping mechanize wget scrape