mirror of
https://github.com/hpware/news-analyze.git
synced 2025-06-23 21:14:23 +00:00
Implement structural updates and optimizations across multiple modules
This commit is contained in:
parent
5d58016b1d
commit
bf38065e52
4 changed files with 19 additions and 4 deletions
|
@ -1,7 +1,18 @@
|
|||
from urllib.request import urlopen
|
||||
import time
|
||||
import re # Regular expressions
|
||||
from urllib.request import urlopen # URL request lib.
|
||||
from bs4 import BeautifulSoup # BeautifulSoup lib.
|
||||
|
||||
url = "https://tw.news.yahoo.com/"
|
||||
headers = {
|
||||
'User-Agent': 'NewsSceraperBot/1.0 (news.yuanhau.com)'
|
||||
}
|
||||
|
||||
#url = "https://tw.news.yahoo.com/"
|
||||
url = "https://news.google.com/home?hl=zh-TW&gl=TW&ceid=TW:zh-Hant"
|
||||
|
||||
page = urlopen(url)
|
||||
html_bytes = page.read()
|
||||
html = html_bytes.decode("utf-8")
|
||||
soup = BeautifulSoup(html, "html.parser")
|
||||
|
||||
page
|
||||
print(soup.find_all("article"))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue