在Python webcrawler中创建文件 [英] Creating files in Python webcrawler

查看:81
本文介绍了在Python webcrawler中创建文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在PyCharm中成功编写了一个网络爬虫,但我需要将其复制到visual studio。简单地复制和粘贴时,无法创建排队和已爬网的文件。任何人都可以告诉我为什么会发生这种情况并建议一种解决方法吗?



输出消息说明:线程'MainThread'(0x19f4)退出时代码为0 (为0x0)。程序'[10060] python.exe'已退出,代码为-1073741510(0xc000013a)。



这是应该创建文件的代码:



我的尝试:



I successfully coded a web crawler in PyCharm, but I need to copy it over to visual studio. When simply copy and pasted, it fails to create my queued and crawled files. Can anyone tell me why this is happening and suggest a way to fix it?

The output message states: The thread 'MainThread' (0x19f4) has exited with code 0 (0x0). The program '[10060] python.exe' has exited with code -1073741510 (0xc000013a).

Here's the code that's supposed to create the file:

What I have tried:

def create_data_files(project_name, base_url):
    queue = project_name + '/queue.txt'

    crawled = project_name + '/crawled.txt'
    if not os.path.isfile(queue):
        write_file(queue, base_url) # the file path and the data
    if not os.path.isfile(crawled):  # look at waiting list, crawl the homepage,  after done crawling moved to crawled
        write_file(crawled, '')

推荐答案

这里有很多种可能性。当您复制粘贴代码时,也许您的缩进变得混乱。也许你试图写信给受保护的位置。或者,它可能只是你在复制粘贴时错过了一两个字符。我先检查这三个,因为他们是最可能的罪魁祸首。



PS:当你说Visual Studio时,我认为你特意指的是Python工具Visual Studio?
There are many possibilities here. Maybe your indentations went haywire when you copy-pasted your code. Maybe you were trying to write to a protected location. Or, it could just be that you simply missed a character or two when copy pasting. I'd check those three first, as they are the most likely culprit.

P.S.: When you said "Visual Studio", I assume you specifically meant Python Tools for Visual Studio?


来自MSDN: [MS-ERREF]:NTSTATUS值 [ ^ ]。

From MSDN: [MS-ERREF]: NTSTATUS values[^].
0xC000013A
STATUS_CONTROL_C_EXIT
{Application Exit by CTRL+C} The application terminated as a result of a CTRL+C.



你需要找出为什么python.exe得到那个中断。


You need to find out why python.exe got that interrupt.


这篇关于在Python webcrawler中创建文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆