我需要帮助来制作一个Python“搜索引擎”,该引擎在html代码中查找特定信息,然后将其添加到列表中,我真的不知道要开始尝试这样做。
我尝试了几件事,但是我不知道从哪里开始正确
import ???
a=["something", "somethinelse", "etc."]
b=[]
c=str(input("Input the wanted str")
def look(x):
y= str("https://www.somewhere.idk/"+x)
#Check if the page has the spesific thing I'm looking for
if somthing in y:
b.append(y)
for i in range(a) :
look(a)
我要做的是获取包含该字符串的网站子目录的列表。
答案 0 :(得分:0)
import requests
from time import sleep
a=["https://www.example1.com/","https://example2.com/","https://example3.com/"]
dat=str(input("What str do you seek: "))
def look(x):
global dat
luk=0
#Loop to look at each of the 1-10 sub directories
for i in range(10):
luk+=1
a.append(luk)
k =str(x)+str(luk)
print(k)
y = requests.get(k)
#Check if the page has the specific thing I'm looking for
if dat in str(y.text):
print("True")
else:
print("False")
sleep(1)
for i in range(len(a)) :
look(str(a[i]))
感谢您使用“请求”库为我指出正确的方向。