File size: 2,695 Bytes
7312ff0
d803a0c
7312ff0
74ee06b
 
c9aae36
 
74ee06b
0246891
c169589
7d4e9a8
 
 
c8b43dc
4d452fd
cc9d81f
 
 
 
4d452fd
cc9d81f
7d4e9a8
c8b43dc
25b05f9
9f588b1
7d4e9a8
 
 
 
 
 
 
 
 
 
a4601fc
 
 
 
 
 
 
74ee06b
58c22b3
 
 
 
b481b5e
7e0ed7b
 
 
 
 
 
 
 
 
af4b9a6
7e0ed7b
 
0246891
7e0ed7b
 
9c7a056
 
2997260
 
7e0ed7b
 
9c7a056
7e0ed7b
 
c169589
0246891
 
 
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
73
74
75
76
import requests
import gradio as gr
from bs4 import BeautifulSoup
from rich import print
from urllib.parse import urlparse

from googlesearch import search
from urllib.parse import parse_qs

def run_lora(prompt,site,start,end):
    

    
    murl = f"https://www.google.com/search?q=site:" +site + "+" +prompt + "&tbs=cdr:1,cd_min:{start},cd_max:{end}"
    surl = "https://www.google.com/search?q=site:" +site + " " +prompt + "after:"+start+"before:" + end
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
    }
    page = requests.get(murl,headers)
    print("https://www.google.com/search?q=site:" +site + " " +prompt + "&tbs=cdr%3A1%2Ccd_min%3A"+start+"%2Ccd_max%3A" + end)
    soup = BeautifulSoup(page.text, 'html.parser')
    search_results = []
    #MjjYud
    for g in soup.find_all('div', class_='MjjYud'):
        print(g)
        title = g.find('h3').text if g.find('h3') else 'No title'
        link = g.find('a')['href']
        snippet = g.find('div', class_='IsZvec').text if g.find('div', class_='IsZvec') else 'No snippet'
        search_results.append({
            'title': title,
            'link': link,
            'snippet': snippet
        })
    
    return search_results

def extract_href(href):
    url = urlparse(href)
    query = parse_qs(url.query)
    if not ('q' in query and query['q'] and len(query['q']) > 0):
        return None
    return query['q'][0]
    
def make_url(query,start,end):
    return f"https://www.google.com/search?q={query}&rlz=1C1CHBF_enUS1024US1025&biw=1564&bih=932&sxsrf=ALiCzsaGPneyPAo-kyllnxBBtXe-FGWorQ%3A1665448856808&source=lnt&tbs=sbd%3A1%2Ccdr%3A1%2Ccd_min%3A{start}%2Ccd_max%3A{end}&tbm=nws"

    
with gr.Blocks() as app:
    gr.HTML("""<html>
  <head>
    <style>
      h1 {
        text-align: center;
      }
    </style>
  </head>
  <body>
    <h1>Get survey</h1>
  </body>
</html>""")
    with gr.Row():
        with gr.Column():
            
            input_textbox = gr.Textbox(lines=5, placeholder="Enter key", label="Input Text")
            input_sitebox = gr.Textbox(lines=5, placeholder="Enter site", label="Site Text")
            start = gr.Textbox(lines=5, placeholder="Enter start", label="Enter start")
            end = gr.Textbox(lines=5, placeholder="Enter End", label="Enter End")
        with gr.Column():
            
            translated_textbox = gr.Textbox(lines=5, placeholder="", label="Result Text")
    info_label = gr.HTML("")
    btn = gr.Button("GetNow")
    btn.click(run_lora, inputs=[input_textbox,input_sitebox,start,end],outputs=[translated_textbox])

app.queue()
app.launch()