我试着运行下面的脚本从goodreads.com获取一些图书数据,从一个标题列表开始。我最近使用了此代码,但现在出现以下错误:

Traceback (most recent call last):

文件“/home/l/gDrive/AudioBookReviews/webcraping/goodreadsscrapper.py”,第3行,in
重新加载(sys)
NameError: name 'reload' is not defined
代码如下:https://pastebin.com/Y5NQiVEp

最佳答案

让我们做一个文件存在检查和访问检查如下:

import os

filePathStr = '/home/l/Downloads/WebScraping/GoodReadsBooksNew.csv'
if os.path.isfile():
    if os.access(filePathStr, os.R_OK):
        print("File exists and is readable")
        fileHandle = open(filePathStr, "w+")
    else:
        print("ERROR: File exists and is NOT readable")
else:
    print("Creating output file "+filePathStr)
    fileHandle = open(filePathStr, "w+")

关于python - Python Web抓取,出现FileNotFound错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57742671/

10-12 07:31
查看更多