Python:sqlalchemy无法识别

时间:2015-08-31 16:30:19

标签: python sqlalchemy pycharm

我安装了一个名为Google Scraper(https://github.com/NikolaiT/GoogleScraper)的模块,我从他的个人资料中复制了这段代码:

import sys
from GoogleScraper import scrape_with_config, GoogleSearchError
from GoogleScraper.database import ScraperSearch, SERP, Link

def basic_usage():
# See in the config.cfg file for possible values
config = {
    'SCRAPING': {
        'use_own_ip': 'True',
        'keyword': 'Let\'s go bubbles!',
        'search_engines': 'yandex',
        'num_pages_for_keyword': 1
    },
    'SELENIUM': {
        'sel_browser': 'chrome',
    },
    'GLOBAL': {
        'do_caching': 'False'
    }
}

try:
    sqlalchemy_session = scrape_with_config(config)
except GoogleSearchError as e:
    print(e)

# let's inspect what we got

for search in sqlalchemy_session.query(ScraperSearch).all():
    for serp in search.serps:
        print(serp)
        for link in serp.links:
            print(link)

应该打印一个链接列表,但没有任何反应。我想SQLalchemy部分无法识别......我之前没有使用过它。我安装了一个名为SQLalchemy的模块,但是我需要设置其他东西吗?什么可能导致此代码不起作用?

0 个答案:

没有答案