我想通过点击多个网页来检索信息(见图 1 和 2)。问题是 a) 没有下一个按钮和 b) 即使页面链接包含一个用于计数的数字,它也不会对手动更改编号做出反应(即不加载下一页)。这使任务变得棘手。
任何人都可以帮助解决这个问题吗?
这是链接的结构(无功能页面) https://sample.io/address/ID#pageSize=100


在 Robbie W 的帮助下开始工作 .. 我使用的代码是:
options.add_argument('windows-size = 1200 x 800')
browser = webdriver.Chrome(chrome_options = options)
browser.get('URL')
page_soup_1 = soup(browser.page_source, "lxml")
items_1 = page_soup_1.find_all("li", {"class": "page-item" })
LenofPage = pd.DataFrame()
count = pd.DataFrame()
for item in items_1 :
string = str(item)
Num = string[string.find('page-item')+23:string.find('\/li')-8]
LenofPage = LenofPage.append({'LenofPage': Num}, ignore_index = True)
Max_pagenum = LenofPage.max()
Max_pagenum_1 = int(Max_pagenum)
count = 1
#items_1 = page_soup.find_all("li", {"class": "page-item active"
}).next_sibling
while count < Max_pagenum_1:
link = browser.find_element_by_xpath('//li[contains(@class, "page-item")
and contains(@class,"active")]/following-sibling::li/a')
link.click()
count = count + 1
time.sleep(3)
print(count)
三国纷争
慕娘9325324
随时随地看视频慕课网APP
相关分类