From edd4843f161360dba4617c575f2cff652f234ac9 Mon Sep 17 00:00:00 2001 From: Gbanyan Date: Fri, 10 Aug 2018 18:13:15 +0800 Subject: [PATCH] search function with selenium gecko --- Main.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Main.py b/Main.py index e69de29..71a7d98 100644 --- a/Main.py +++ b/Main.py @@ -0,0 +1,36 @@ +import scrapy +from bs4 import BeautifulSoup +import requests +from selenium import webdriver +import html5lib +import re +import sys + + +up_search_url = "https://www.uptodate.com/contents/search?search=" + +def do_uptodate_search_with_gecko(key_word): + print(up_search_url + key_word) + driver = webdriver.Firefox() + driver.get(up_search_url + key_word) + html = driver.page_source + soup = BeautifulSoup(html, 'html.parser') + articles_links = soup.find_all(".search-results") #Still unable to catch the wanted result + for links in articles_links: + print(links) + +def do_uptodate_search(key_word): + print(up_search_url + key_word) + driver = webdriver.Firefox() + 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") + + for link in articles_links: + print(link) + +if __name__ == '__main__': + key_word = input("Please enter your keyword: ") + do_uptodate_search_with_gecko(key_word)