我尝试编写以下方法。但是我需要一种有效的方式来编写此python代码

时间:2019-06-27 00:39:34

标签: python

def search_domain(domain):
    record_list = []
    print("[*] Trying target domain: {}".format(domain)) 
    for index in index_list:
        print("[*] Trying index {}".format(index))
        cc_url = "http://index.commoncrawl.org/CC-MAIN-"
        cc_url += index
        cc_url += "-index?" 
        cc_url += "url="
        cc_url += domain
        cc_url += "&matchType=domain&output=json"
        # Make request to CommonCrawl index
        response = requests.get(cc_url)
        if response.status_code == 200:
            records = response.content.splitlines()
            for record in records:
                record_list.append(json.loads(record))  
            print("[*] Added {}results.".format(len(records)))
    print("[*] Found a total of {} hits.".format(len(record_list))) 
    return record_list

0 个答案:

没有答案