Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- from bs4 import BeautifulSoup as bs
- from requests import get, exceptions
- from re import findall
- USER_AGENT = "Nery App 1.0"
- BASE_URL = "https://www.google.com/search?q={}"
- def main():
- while True:
- search_term = input("\nSearch: ").strip()
- if not search_term:
- continue
- try:
- response = get(BASE_URL.format(search_term), headers={"User-Agent": USER_AGENT})
- soup = bs(response.content, "lxml")
- for link in soup.find_all("a"):
- href = link.get("href")
- if href and findall(r"(http|https)\:\/\/.*", href):
- print(href)
- except exceptions.RequestException as err:
- print(f"Error: {err}")
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement