代码中存在一些缺陷和错误,需要进行修改:

  1. google_serach函数中,文件名的格式不正确,需要修改为filename = f'{filename}.txt'

  2. google_serach函数中,请求头信息中的refererorigin字段需要修改为https://www.google.com

  3. google_serach函数中,代理信息需要修改为proxies = {'http': 'http://127.0.0.1:10809', 'https': 'http://127.0.0.1:10809'},这里使用的是Shadowsocks代理。

  4. google_serach函数中,获取URL的代码存在错误,需要修改为get_url = [url.find('a').get('href') + '\n' for url in find_div if 'google.com.tw' not in url.find('a').get('href')]

  5. write_info函数中,写入文件时需要先判断列表是否为空,不为空时才进行写入。

  6. 在主函数中,需要修改input函数的提示信息,将output file改为output filename

  7. 在主函数中,需要修改input函数的参数,将变量名dorks_file改为dorks_filename

  8. 在主函数中,程序运行完毕后需要打印提示信息,可以使用print函数实现。

修改后的代码如下

哪里有错误不输出文件卡在输出界面import requestsimport timeimport osimport urllib3import sysimport randomfrom bs4 import BeautifulSoupfrom concurrentfutures import ProcessPoolExecutor ThreadPoolExecutorfrom threading

原文地址: http://www.cveoy.top/t/topic/hw2q 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录