python爬虫结果显示ok
时间: 2023-11-21 17:06:16 浏览: 54
Python爬虫结果显示OK通常意味着爬虫程序已经成功地获取了所需的数据并将其显示在终端或其他输出设备上。在引用中提供的示例代码中,程序使用requests库向百度搜索引擎发送请求,并使用BeautifulSoup库解析响应HTML页面。然后,程序从HTML页面中提取所需的数据,并将其显示在终端上。如果程序成功地提取了所需的数据并将其显示在终端上,则可以认为Python爬虫结果显示OK。
相关问题
python爬虫图片代码
以下是一个Python爬虫图片的代码示例:
```python
import requests
import re
import urllib
from io import BytesIO
from PIL import Image
def get_pictures(url):
data = requests.get(url).text
regex = r'<img src="(.*?.jpg)"'
pa = re.compile(regex)
images = re.findall(pa, data)
i = 0
print('*****Starting*****')
for image in images:
if '" data-original="' in image:
address = image.split('" data-original="')[1]
else:
address = image
i += 1
image = requests.get(address)
image = Image.open(BytesIO(image.content))
image.save('D:\\111\\' + str(i) + '.jpg')
print("*****Ending*****")
if __name__ == '__main__':
url = "http://soso.nipic.com/q_中国交通and隧道景观_g_0.html"
get_pictures(url)
print("OK!!!")
```
python爬虫pycharm配置
```python
# 配置PyCharm解释器为Miniconda环境中的Python
1. 打开PyCharm,点击File -> Settings -> Project: your_project_name -> Python Interpreter。
2. 点击齿轮图标,选择Add...,在弹出的窗口中选择Conda Environment -> Existing environment -> Interpreter。
3. 在Interpreter选项中选择Miniconda环境中的Python解释器路径,点击OK按钮完成配置。
4. 配置完成后,即可顺利使用Miniconda环境中的Python进行爬虫开发。
```