daily pastebin goal
2%
SHARE
TWEET

Untitled

a guest May 22nd, 2018 51 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2.  
  3. from bs4 import BeautifulSoup
  4.  
  5. import re
  6.  
  7. from selenium import webdriver
  8.  
  9.  
  10. query = input("What would you like to search: ")
  11.  
  12. query = query.replace(" ","+")
  13.  
  14. base = "http://www.google.de"
  15.  
  16. query = "https://www.google.com/search?q=" + query
  17.  
  18. driver = webdriver.Firefox(executable_path=r'C:UsersSwapnaliAppDataLocalgeckodriver.exe')
  19.  
  20. driver.get(query)
  21.  
  22. elem1 = driver.find_element_by_link_text("More places")
  23.  
  24. elem1.click()
  25.  
  26. Current_Url = driver.current_url
  27.  
  28. print('Current_Url')
  29.  
  30. print(Current_Url)
  31.  
  32. r = requests.get(Current_Url)
  33.  
  34. html_doc = r.text
  35.  
  36. soup = BeautifulSoup(html_doc, 'html.parser')
  37.  
  38. for s in soup.find('body'):
  39.  
  40.     allDetail = s.text
  41.  
  42.     print('allDetail')
  43.  
  44.     print(allDetail)
  45.  
  46.     for next_page in soup.select(".fl"):
  47.  
  48.                 res = requests.get(query + next_page.get('href'))
  49.  
  50.                 soup = BeautifulSoup(res.text,"html.parser")
  51.  
  52.     for i in re.findall(r'[+(]?[1-9][0-9 .-()]{8,}[0-9]', s.text):
  53.  
  54.             print(i)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top