首页 > 解决方案 > 如何解决给定网络抓取工具中的意外 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

标签: pythonweb-scrapingbeautifulsoupweb-scraping-language

解决方案


推荐阅读