【发布时间】:2020-05-13 22:28:55
【问题描述】:
我正在尝试得到响应 https://us.vestiairecollective.com/members/profile-2241096.shtml#currentpgn=2 但是当使用 requests get 方法访问时,我得到了响应 https://us.vestiairecollective.com/members/profile-2241096.shtml#currentpgn=0 当前pgn的每个参数号都面临这个问题
from requests import get
from bs4 import BeautifulSoup
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'
}
resp = get("https://us.vestiairecollective.com/members/profile-2241096.shtml#currentpgn=2", headers=headers)
soup = BeautifulSoup(resp.text, 'lxml')
divs = soup.find('div', class_='catalog-list medium').find_all("div", recursive=False)
for div in divs:
print(div.a['href'])```
【问题讨论】:
-
你能显示一些输出吗?我得到了预期的输出。
标签: python python-3.x web-scraping beautifulsoup python-requests