mirror of
https://github.com/tcsenpai/mysides.git
synced 2025-06-06 02:55:21 +00:00
Fixed a return error
This commit is contained in:
parent
adabc100e6
commit
578dc164c7
7
main.py
7
main.py
@ -74,7 +74,8 @@ def extract_data(url):
|
|||||||
response = requests.get(url, timeout=5)
|
response = requests.get(url, timeout=5)
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
links = apnews.fetchAndDigest(soup)
|
links = apnews.fetchAndDigest(soup)
|
||||||
transform_links(links)
|
datas = transform_links(links)
|
||||||
|
return datas
|
||||||
|
|
||||||
def handle_pagination(soup):
|
def handle_pagination(soup):
|
||||||
next_page = soup.find("a", {"rel": "next"})
|
next_page = soup.find("a", {"rel": "next"})
|
||||||
@ -89,8 +90,8 @@ def main():
|
|||||||
all_data = []
|
all_data = []
|
||||||
|
|
||||||
while url:
|
while url:
|
||||||
data = extract_data(url)
|
datas = extract_data(url)
|
||||||
all_data.extend(data)
|
all_data.extend(datas)
|
||||||
url = handle_pagination(
|
url = handle_pagination(
|
||||||
BeautifulSoup(requests.get(url, timeout=5).text, "html.parser")
|
BeautifulSoup(requests.get(url, timeout=5).text, "html.parser")
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user