【发布时间】:2017-09-27 23:26:57
【问题描述】:
我正在学习python爬虫,我想知道如何处理位于以下网址中的“加载更多”按钮:
https://www.photo.net/search/#//Sort-View-Count/All-Categories/All-Time/Page-1
(我试图爬取所有图片)
我的当前代码正在使用 beautifulsoup:
from urllib.request import *
from http.cookiejar import CookieJar
from bs4 import BeautifulSoup
url = 'https://www.photo.net/search/#//Sort-View-Count/All-Categories/All- Time/Page-1'
cj = CookieJar()
opener = build_opener(HTTPCookieProcessor(cj))
try:
p = opener.open(url)
soup = BeautifulSoup(p, 'html.parser')
except Exception as e:
print(str(e))
【问题讨论】:
-
您是否尝试增加 URL 末尾的页码?您可以尝试循环浏览一些页面并抓取其中的内容。
-
是的,我试过了,但除非你点击那个按钮,否则它无法加载。
标签: python web-crawler