python - 使用 Scrapy 发送此 FormRequest 后,Web 服务器返回 "500 Internal Server Error"

标签 python scrapy

我根据httpFox(Firefox addon)的内容构造了以下FormRequest。但是,Web 服务器总是返回“500 内部服务器错误”。

有人可以帮我解决这个问题吗?

原网址为: http://www.intel.com/jobs/jobsearch/index_ne.htm?Location=200000008

这是我的蜘蛛的骨架:

class IntelSpider(BaseSpider):  
    name = "intel.com"  
    allowed_domains = ["taleo.net"]  

    def start_requests(self):  
        req_china = FormRequest("https://intel.taleo.net/careersection/10020/moresearch.ajax",  
                                formdata={
                                   'iframemode': '1',
                                   'ftlpageid': 'reqListAdvancedPage',
                                   'ftlinterfaceid': 'advancedSearchFooterInterface',
                                   'ftlcompid': 'SEARCH',
                                     ... # commentsThere are a lots of data here.#
                                   'location1L2': '-1',
                                   'dropListSize': '25',
                                   'dropSortBy': '10'},
                                callback=self.test)

        return [req_china]

def test(self, response):
    print response.body
    return 

最佳答案

您的问题来自intel网页,而不是来自scrapy。 但... 表单通常有一些隐藏字段,发出 POST 请求的最佳方式是这样的:

def start_requests(self,response):  
        req_china = FormRequest.from_response(response=response,  
                                formdata={
                                   'iframemode': '1',
                                   'ftlpageid': 'reqListAdvancedPage',
                                   'ftlinterfaceid': 'advancedSearchFooterInterface',
                                   'ftlcompid': 'SEARCH',
                                     ... # commentsThere are a lots of data here.#
                                   'location1L2': '-1',
                                   'dropListSize': '25',
                                   'dropSortBy': '10'},
                                callback=self.test)

关于python - 使用 Scrapy 发送此 FormRequest 后,Web 服务器返回 "500 Internal Server Error",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4008371/

相关文章:

python - Scrapy - 使用 header 和请求负载模拟 AJAX 请求

python - 使用 etree 从所有元素中删除所有数据属性

Python 从普通函数调用协程

python - Python 中的面向对象示例

python - 使用 python 获取上周日期?

python - 如何使用 xpath 中具有标签信息的变量来提取

python - Scrapy SgmlLinkExtractor如何使用正则表达式定义规则

python 语言环境无法在我的机器上运行 (osx 10.7.4)

python C++ 扩展 : symbol not defined error

python - C-Python 扩展中的全局 PyObject* 变量