我试图从航空邮政网页上搜寻商店的位置,但我这样做的方式似乎行不通,有人能指导我吗?或者告诉我我做错了什么?这是我的代码:
import requests
from lxml.html import fromstring
from bs4 import BeautifulSoup
with requests.Session() as c:
url = 'http://www.aeropostale.com/storeLocator/index.jsp'
response = requests.get(url)
print(response)
# {'city': '', 'searchType': 'POSTAL_CODE', 'typeId': '0', 'findByZip': None, 'action': 'SEARCH_FOR_STORES', 'state': '', 'radius': '5', 'postalCode': None}
html = fromstring(response.content)
payload = dict(html.forms[2].fields)
print(payload)
# {'city': '', 'searchType': 'STATE', 'typeId': '0', 'findByZip': None, 'action': 'SEARCH_FOR_STORES', 'state': 'LA', 'radius': '50', 'postalCode': None}
payload.update(({'searchType': 'STATE', 'state': 'LA', 'radius': '50'}))
print(payload)
locations = c.post(url, data=payload)
print(locations)
r = c.get('http://www.aeropostale.com/storeLocator/results.jsp')
print(BeautifulSoup(r.content).text)
它没有得到发布的结果我不知道为什么,当我试图找到http://www.aeropostale.com/storeLocator/results.jsp的形式时 它似乎没有它给我的这个表格张贴的表格
^{pr2}$有人能帮我吗?在
您将查询发布到错误的位置,然后忽略响应。不要对
results.jsp
页使用单独的GET
。在改为发到
results.jsp
位置:演示:
^{pr2}$相关问题 更多 >
编程相关推荐