【发布时间】:2017-04-15 00:48:53
【问题描述】:
我使用的请求效果很好,但是使用这个特定的 url,我得到了重定向循环中断。
s = requests.Session()
page = s.get('http://pe.usps.gov/text/pub28/28apc_002.htm')
tree = html.fromstring(page.content)
street_type = tree.xpath(r"//*[@id='ep533076']/tbody/tr[2]/td[1]/p/a")
print(street_type)
我特别想知道是否有一种方法可以为请求分配标头以避免重定向。我已经测试了实际的 url,它看起来是有效的。
谢谢
【问题讨论】:
标签: python url python-requests