File size: 2,307 Bytes
2c86df9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import streamlit as st
import requests
from bs4 import BeautifulSoup

def search_game_results(game_name):
    search_url = f"https://gamingbeasts.com/?s={game_name}"
    response = requests.get(search_url)
    
    if response.status_code == 200:
        soup = BeautifulSoup(response.text, 'html.parser')
        game_entries = soup.find_all('div', class_='inside-article')
        
        if not game_entries:
            return None
        
        results = []
        for entry in game_entries:
            title_elem = entry.find('h2', class_='entry-title').find('a')
            title = title_elem.text if title_elem else "Title not found"
            link = title_elem['href'] if title_elem else "Link not found"
            
            categories_elem = entry.find('span', class_='cat-links')
            categories = [category.text for category in categories_elem.find_all('a')] if categories_elem else []
            
            results.append({
                'title': title,
                'link': link,
                'categories': categories
            })
        
        return results
    else:
        return None

def scrape_download_url(url):
    response = requests.get(url)
    if response.status_code == 200:
        soup = BeautifulSoup(response.text, 'html.parser')
        url_input_elem = soup.find('input', {'name': 'url'})
        
        if url_input_elem:
            download_url = url_input_elem['value']
            return download_url
    return None

def get_download_urls(game_name):
    results = search_game_results(game_name)
    
    if isinstance(results, list):
        download_urls = []
        for result in results:
            download_url = scrape_download_url(result['link'])
            if download_url:
                download_urls.append(download_url)
        
        return download_urls
    else:
        return None

st.title("Game Download URL Finder")

game_name = st.text_input("Enter the name of the game:")
if game_name:
    download_urls = get_download_urls(game_name)
    
    if download_urls:
        st.subheader(f"Download URLs for '{game_name}':")
        for i, download_url in enumerate(download_urls, start=1):
            st.write(f"{i}. {download_url}")
    else:
        st.write("No download URLs found for this game.")