Last active
August 7, 2025 16:16
-
-
Save AdelMmdi/3907a8e5444dfdd89bd3c74ebf3ea2e2 to your computer and use it in GitHub Desktop.
Game research for system requirements selected for a computer with the word
This file contains hidden or 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
| import webbrowser | |
| import time, random | |
| import requests | |
| from bs4 import BeautifulSoup | |
| def get_all_links(url): | |
| """ | |
| Fetches a webpage and extracts all URLs from anchor tags. | |
| """ | |
| try: | |
| response = requests.get(url, cookies='',headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0'}) | |
| response.raise_for_status() # Raise an exception for bad status codes | |
| # Accessing all cookies | |
| for cookie in response.cookies: | |
| print(f"Name: {cookie.name}, Value: {cookie.value}") | |
| # Accessing a specific cookie by name | |
| if 'session_id' in response.cookies: | |
| session_cookie_value = response.cookies['session_id'] | |
| print(f"Session ID: {session_cookie_value}") | |
| except requests.exceptions.RequestException as e: | |
| print(f"Error fetching the URL: {e}") | |
| return [] | |
| soup = BeautifulSoup(response.text, 'html.parser') | |
| links = [] | |
| for anchor_tag in soup.find_all('a'): | |
| href = anchor_tag.get('href') | |
| if href: # Ensure the href attribute exists | |
| links.append(href) | |
| return links | |
| def research(number_start_page_from): | |
| S = 'https://par30games.net/pc/page/' | |
| exist = True | |
| special_games = [] | |
| print('number start page from', number_start_page_from, 'to you click Ctrl+C') | |
| # to end of number at pages | |
| while exist: | |
| try: | |
| number_start_page_from += 1 | |
| list_games = get_all_links(S+str(number_start_page_from)) | |
| special_games += list_games[170:186] | |
| print('page:', number_start_page_from) | |
| except KeyboardInterrupt as KeyError: | |
| exist = False | |
| with open('links.txt', 'w+') as f: | |
| #print('s'*20,special_games ) | |
| for l in special_games: | |
| #print(l) | |
| f.write(l+'\n') | |
| f.close() | |
| def remove_duplicate_lines(input_file, output_file): | |
| seen_lines = set() | |
| with open(input_file, 'r', encoding='utf-8') as infile, open(output_file, 'w', encoding='utf-8') as outfile: | |
| for line in infile: | |
| if line not in seen_lines: | |
| outfile.write(line) | |
| seen_lines.add(line) | |
| def ready_for_collect(select, path_links, black_list): | |
| f = open(select, 'w+') | |
| # Send an HTTP GET request | |
| url = "" | |
| for url in open(path_links).readlines(): | |
| name = url[-1:].rfind('/') | |
| print(url[name:]) | |
| GAME = url[name:] | |
| response = requests.get(url, headers={'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0"}) | |
| # Parse the HTML content | |
| soup = BeautifulSoup(response.text, 'html.parser') | |
| # Find the element by its ID | |
| element = soup.find(dir="ltr") | |
| #e = element.format_string | |
| # Print the element or its content | |
| if element: | |
| #e = e.replace('<br/>', ',') | |
| ##e = e.replace('</p>', ',') | |
| e = element.text | |
| #f.write(element.) | |
| #print(element) # Full HTML of the element | |
| # Text inside the element | |
| if not any(item in e for item in black_list): | |
| #if 'GTX' not in e and '12 GB RAM' not in e and '4GB VRAM ' not in e and 'Gtx' not in e and '6GB VRAM' not in e: | |
| print(e) | |
| print(url) | |
| webbrowser.open(url, new=0,autoraise=True) | |
| f.write(url) | |
| # Generate a random integer between 10 and 20 (inclusive) | |
| random_number = random.randint(3, 7) | |
| print('wait: ', random_number) | |
| time.sleep(random_number) | |
| print() | |
| else: | |
| print("Element with the specified ID not found.") | |
| f.close() | |
| if __name__ == "__main__": | |
| research(350) | |
| # Example usage | |
| db = 'database.txt' | |
| input_file = 'links.txt' # Replace with your input file name | |
| output_file = 'games.txt' # Replace with your desired output file name | |
| remove_duplicate_lines(input_file, output_file) | |
| ready_for_collect(db, output_file, ['GTX', 'RTX', '12 GB RAM', '4GB VRAM ', 'Gtx', '6GB VRAM']) | |
| '''with open(db, 'r') as f: | |
| for url in f.readlines(): | |
| print(url) | |
| #url = "https://www.example.com" | |
| webbrowser.open(url, new=0,autoraise=True) # Opens in the default browser | |
| time.sleep(4)# need to read and collect | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment