代码很简单,但是我很难弄清楚选择器
import csv
import time
from bs4 import BeautifulSoup
import requests
source = requests.get('https://website.com').text
soup = BeautifulSoup(source, 'lxml')
nextpage= soup.find("a", string="3").get('href')
print (nextpage)
gives me the href associated with 3... but when I try "Next"
I am getting None error
路径是:
<a class="" href="https://website.com;page=2">Next ›</a>]
我究竟做错了什么?还有另一种选择下一个选择器的方法...
代码(如下)有效
nextpage= main_pagination.find_all('a', class_='')[3]
但是该代码的问题是,下一个可能是[5]在另一个搜索上。我需要此页面的通用解决方案...