首页 > 解决方案 > 如何在scrapy中从sql(pyodbc)中读取数据

问题描述

我正在尝试使用 PyODBC 和 Scrapy 从我的 SQL 数据库中读取数据。我该怎么做呢?这是我到目前为止所拥有的:

import scrapy
import pyodbc
import pandas as pd
table = pd.read_sql_query("select top 10 * from Organization where countryid = 13 and revenue='unknown'",con)

class ZoominfoSpider(scrapy.Spider):
    name = 'zoominfo'

    def start_requests(self):
        #con = database_connect():
        for index in table.index:
            company = table["Name"][index].strip()
            url = f"https://www.google.com.ua/search?q={company + '+link+overview'}"
            req = scrapy.Request(url=url, callback=self.parse_google_results, cb_kwargs={"company": company})
            req.meta['proxy'] = None
            yield req

标签: pythonweb-scrapingscrapy

解决方案


推荐阅读