<p>我遵照您的建议,将代码替换为:</p>
<pre><code>#!/bin/bash
# -*- coding: utf-8 -*-
#Codded by Naylor From Exploit-Zone
#Join-us ! ==> https://forum.exploit-zone.eu/
#Create a folder nammed ==> Dork
from urllib.request import *
import os
from bs4 import BeautifulSoup
"""
http ==> 80
https ==> 443
200 ==> OK
400 ==> Bad request
403 ==> Forbidden
404 ==> Not found
"""
def checker():
dorks = open("Dork/{}.txt".format(txtdork_path),"r")
list_dorks = []
dorks_lines = dorks.readlines()
tot_dorks = len(dorks_lines)
tot_dorks -= 1
for line in dorks_lines:
list_dorks.append(line)
print("\t{}\n ( ) Has been charged\n".format(line))
print("\n( ) All {} dorks charged\n".format(tot_dorks))
dorks.close()
choosen_dork = int(input("Witch line do you want to use ? (write a number between 0 and {})\n>".format(tot_dorks)))
if choosen_dork >= 0 and choosen_dork <= tot_dorks:
pass
else:
print("The choosen number is to big !")
choosen_dork = int(input("Witch line do you want to use ? (write a number between 0 and {})\n>".format(tot_dorks)))
dork_used = str(list_dorks[choosen_dork])
print("\n( ) Selected Dorks ==> {}".format(dork_used))
url_dorked ="https://www.google.com/search?q={}&sources=lnms&tbs=nws".format(dork_used)
req_fbypss = Request(url_dorked, headers = {'User-Agent': 'Mozilla/5.0'}) #user-agent to bypass Anti-crawl)
init_google = urlopen(req_fbypss)#init connection
print("( ) Google connection response ==> {}\n".format(init_google.code))
html_google = init_google.read() #read response of init
html_decoded = html_google.decode("ISO-8859-1")#like utf-8
soup = BeautifulSoup(html_google, "html.parser") #start an html html_parser
result_link = soup.findAll('a')
for i in result_link:
print(i,"\n")
"""
with open("dork_{}.txt".format(choosen_dork),"a") as f:
for result in result_1:
f.write(result)
"""
print("\n\n\tWelcome\n\n")
print("here Are the available dork file :\n")
dork_list = str(os.listdir('Dork/.'))
print("=> {}\n".format(dork_list))
txtdork_path = str(input("Enter dork file's name (without '.txt'/'[]'/''')\n>"))
check_file = os.path.isfile("Dork/{}.txt".format(txtdork_path))
if check_file == True:
print("\n( ) {} as been selected".format(txtdork_path))
else:
print("\nWrong name!\n (write only the name of the .txt file like : Google dork 2019)\n the .txt file have to be on the Dork folder\n\n")
exit()
checker()
</code></pre>
<p>所以我替换了这个url,因为我放的是一个错误的url,我忘记替换了</p>
<p>我改变了url的位置,把他放在了dork_使用的选择之后</p>
<p>他现在要求用ISO-8859-1而不是utf-8进行解码
但仍然不起作用:/</p>