Ниже приведен пример кода. Когда я нажимаю на ссылку: "https://www.google.com/search?q=Center+ ... 19&tbm=nws", она дает мне статьи для результатов поиска между моими датами, однако созданный список не отражает появившиеся статьи.
Код: Выделить всё
import requests
import re
import bs4
import urllib
import pandas as pd
from bs4 import BeautifulSoup
from bs4 import BeautifulSoup as bs
from urllib.request import urlopen
search = 'Center+for+Community+Alternatives'
start_date = '5/2/2019'
end_date = '5/10/2019'
# The link to be searched initially
link4 = 'https://www.google.com/search?q=' + search + '&tbs=cdr:1,cd_min:' + start_date + ',cd_max:' + end_date + '&tbm=nws'
# Searching the link
page = requests.get(link4)
# Gathering the page content from the link
soup = BeautifulSoup(page.content)
# Finding all links
links = soup.findAll("a")
# Fixing up the links and putting them into a list
empty = []
fixed_list = []
finished_list = []
for link in soup.find_all("a",href=re.compile("(?
Подробнее здесь: [url]https://stackoverflow.com/questions/73007290/returning-news-articles-on-the-news-feature-of-google-between-specific-dates-in[/url]
Мобильная версия