pip install newspaper3k pip install git+https://github.com/codelucas/newspaper.git python import newspaper user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' config = newspaper.Config() config.browser_user_agent = user_agent article = newspaper.Article(url, config=config) python import newspaper from selenium import webdriver driver = webdriver.Chrome() driver.get(url) html = driver.page_source article = newspaper.Article(url) article.set_html(html) article.parse() python import newspaper article = newspaper.Article(url) article.download() article.set_html(article.html.decode('utf-8', 'ignore')) article.parse() python import newspaper from bs4 import BeautifulSoup article = newspaper.Article(url) article.download() article.parse() soup = BeautifulSoup(article.html, 'html.parser') images = soup.find_all('img') for image in images: image_url = image['src']


上一篇:
下一篇:
切换中文