【发布时间】:2014-06-02 09:54:52
【问题描述】:
我想从 cbfcindia 删除有关所有电影的数据。
1) 在 SEARCH BOX 中,如果 Title = "a" 则填充所有以 "a" 开头的电影,(在 URL 中,va=a&Type=search) http://cbfcindia.gov.in/html/uniquepage.aspx?va=a&Type=search
2) 电影列表填充在表格中,现在这里是 JAVASCRIPT,如果我点击第一部电影,我会输入它的详细信息,我希望为所有电影抓取所有这些详细信息。 但我连一部电影都做不到。
3)我的观察:在源代码中有以下功能:
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
我们需要根据JS来传递参数。但我不知道怎么做。
items.py
from scrapy.item import Item, Field
class CbfcItem(Item):
MovieName = Field()
MovieLanguage = Field()
Roffice = Field()
CertificateNo = Field()
CertificateDate = Field()
Length = Field()
NameofProducer = Field()
#pass
cbfcspider.py
from cbfc.items import CbfcItem
class MySpider(BaseSpider):
name = 'cbfc'
allowed_domains= ["http://cbfcindia.gov.in/"]
start_urls = ["http://cbfcindia.gov.in/html/uniquepage.aspx?va=a&Type=search"]
def parse(self, response):
hxs = HtmlXPathSelector(response)
titles = hxs.select("//tbody") #Check
print titles
items = []
for titles in titles:
print "in FOR loop"
item = CbfcItem()
item ["MovieName"] = hxs.path('//*[@id="lblMovieName"]/text()').extract()
item ["MovieLanguage"] = hxs.path('//*[@id="lblLanguage"]').extract()
item ["Roffice"] = hxs.path('//*[@id="lblRegion"]').extract()
item ["CertificateNo"] = hxs.path('//*[@id="lblCertNo"]').extract()
item ["CertificateDate"] = hxs.path('//*[@id="Label1"]').extract()
item ["Length"] = hxs.path('//*[@id="lblCertificateLength"]').extract()
item ["NameofProducer"] = hxs.path('//*[@id="lblProducer"]').extract()
items.append(item)
print "this is ITEMS"
return items
print "End of FOR"
【问题讨论】:
标签: javascript python scrapy