python 第三课 爬虫
已安装python环境,cmd文件中运行以下三句话
python -m pip install requests
python -m pip install parsel
python -m pip install urllib3
爬虫原理是从网页源代码中抓取想要的数据
贴代码:从豆瓣网上抓取前10页的信息
from re import M, X
from tkinter import Y
from matplotlib import pyplot as plt
import numpy as np
from pyparsing import alphanums
X=np.random.randint(0,100,30)
Y=np.random.randint(0,100,30)
fig,ax=plt.subplot()
v = np.random.randint(0,100,30)
ax.scatter(X,Y,s=200,c=v,alpha=0.7)
i,j = 0,0
while i<30:
j = 0
#j=28,0-29
while j<29:
d = (X[i]-X[j+1])**2 + (Y[i]-Y[j+1])**2
if d <=2500:
ax.plot([X[i],X[j+1]],[Y[i],Y[j+1]])
j = j + 1
i = i + 1
plt.show()
print(X,Y)
浙公网安备 33010602011771号