python - 如何解决给定网络抓取工具中的意外 EOF 错误?
问题描述
目前,我正在自学网页抓取。
三天后,我掌握了 Beautifulsoup 单个查询的窍门,但我在循环中使用for ....来获取多个块。
这是我的设置:
import requests
import numpy as np
import pandas as pd
from bs4 import BeautifulSoup
import matplotlib.pyplot as plt
%matplotlib inline
quotes_url = 'http://quotes.toscrape.com/'
quotes_response = requests.get(quotes_url)
# Parse the whole HTML page using BeautifulSoup
soup = BeautifulSoup(quotes_response.text, 'html.parser')
quotes = soup.find_all('div', class_quote)
在引号中引用:
我总是在 Google Colab 中收到此错误。
文件“”,第 3 行引号中的引号:^ SyntaxError:解析时意外 EOF
例如,是否添加无关紧要。
quote_text = quotes.find('span', class_='text').text
解决方案
推荐阅读
- httprequest - 尝试通过使用 VB 脚本发送 json 数据来发出 http post 请求并期待响应
- r - 如何使 geom_line() 在时间序列图中更平滑
- css - css - 卡片块,如何定位和调整图像大小
- android - 在颤动中重复相邻的图像
- python-3.x - PyQt5 - QTableWidget 水平滚动条
- python-3.x - 如何使用 shutil.rmtree.avoids_symlink_attacks?
- go - gl.DrawElements 似乎使用了不正确的索引
- java - 尝试启动真正的安卓手机的安卓应用程序时出现“未知的服务器端错误”
- python-3.x - 寻找更有效的算法
- javascript - 如何将对象数组更改为简单对象