search_apis/search_site.py
def search_site(url_file, out_file, keyword):
    """
    Write results as json line objects into out_file
    Format of each json object:
        list<str>: list of urls. First url is the main site
    """
    urls = URLUtility.load_urls(url_file)
    site2urls = read_json(out_file)
    k = 10
   
    out = open(out_file, "a+")
    for i, url in enumerate(urls):
        site = URLUtility.get_host(url)
        if site not in site2urls:
            results = bing_search.search_site(keyword, url, 10)
            results = [site, url] + results
            json.dump(results, out)
            out.write("\n")
    out.close()

    Write results as json line objects into out_file
    Format of each json object:
        list<str>: list of urls. First url is the main site
    
Write results as json line objects into out_file
Format of each json object:
list: list of urls. First url is the main site
Write results as json line objects into out_file Format of each json object : list : list of urls . First url is the main site
def search_site(url_file, out_file, keyword):
    urls = URLUtility.load_urls(url_file)
    site2urls = read_json(out_file)
    k = 10
    out = open(out_file, "a+")
    for i, url in enumerate(urls):
        site = URLUtility.get_host(url)
        if site not in site2urls:
            results = bing_search.search_site(keyword, url, 10)
            results = [site, url] + results
            json.dump(results, out)
            out.write("\n")
    out.close()
def search_site ( url_file , out_file , keyword ) : urls = URLUtility . load_urls ( url_file ) site2urls = read_json ( out_file ) k = 10 out = open ( out_file , "a+" ) for i , url in enumerate ( urls ) : site = URLUtility . get_host ( url ) if site not in site2urls : results = bing_search . search_site ( keyword , url , 10 ) results = [ site , url ] + results json . dump ( results , out ) out . write ( "\n" ) out . close ( )
Write results as json line objects into out_file
Format of each json object:
list<str>: list of urls.
Write results as json line objects into out_file Format of each json object : list<str > : list of urls .
"""
    Write results as json line objects into out_file
    Format of each json object:
        list<str>: list of urls. First url is the main site
    """
url_file
out_file
keyword