Found Uptodate API and apply with requests
This commit is contained in:
parent
edd4843f16
commit
2c327a733d
21
Main.py
21
Main.py
@ -6,8 +6,10 @@ import html5lib
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
#Def the Uptodate URI for use
|
||||
up_search_url = "https://www.uptodate.com/contents/search?search="
|
||||
up_api_url = "https://www.uptodate.com/services/app/contents/search/2/json?&language=en&max=10&search="
|
||||
up_prefix_url = "https://www.uptodate.com"
|
||||
|
||||
def do_uptodate_search_with_gecko(key_word):
|
||||
print(up_search_url + key_word)
|
||||
@ -19,18 +21,21 @@ def do_uptodate_search_with_gecko(key_word):
|
||||
for links in articles_links:
|
||||
print(links)
|
||||
|
||||
def do_uptodate_search(key_word):
|
||||
def do_uptodate_search_with_headless(key_word):
|
||||
print(up_search_url + key_word)
|
||||
driver = webdriver.Firefox()
|
||||
option = webdriver.ChromeOptions()
|
||||
option.add_argument('headless')
|
||||
driver = webdriver.Chrome(chrome_options=option)
|
||||
driver.get(up_search_url + key_word)
|
||||
html = driver.page_source
|
||||
soup = BeautifulSoup(html, 'html.parser')
|
||||
print(html)
|
||||
articles_links = soup.find_all("div.search-result")
|
||||
articles_links = soup.select("#search-results-container")
|
||||
print(articles_links)
|
||||
|
||||
for link in articles_links:
|
||||
print(link)
|
||||
def do_uptodate_search_with_uptodate_api(key_word):
|
||||
search_results = requests.get(up_api_url + key_word)
|
||||
print(search_results.json())
|
||||
|
||||
if __name__ == '__main__':
|
||||
key_word = input("Please enter your keyword: ")
|
||||
do_uptodate_search_with_gecko(key_word)
|
||||
do_uptodate_search_with_uptodate_api(key_word)
|
||||
|
Loading…
Reference in New Issue
Block a user