-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
83 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import requests | ||
from bs4 import BeautifulSoup | ||
x = input("請輸入維基百科網址:") | ||
x = input("想要查甚麼: ") | ||
url = 'https://zh.m.wikipedia.org/zh-tw/' + x | ||
response = requests.get(url) | ||
if response.status_code == 200: | ||
page_content = response.text | ||
soup = BeautifulSoup(page_content, 'html5lib') | ||
|
||
wiki = soup.find_all('p')[0].get_text() | ||
if wiki.replace("\n", "").strip() == '': | ||
wiki = soup.find_all('p')[1].get_text() | ||
print(wiki) | ||
response = requests.get(url).text | ||
soup = BeautifulSoup(response, 'html5lib') | ||
wiki = soup.find_all('p')[0].get_text() | ||
if wiki.replace("\n", "").strip() == '': | ||
wiki = soup.find_all('p')[1].get_text() | ||
print(wiki) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters