나는 거미줄을 사용하여 출력 페이지를 구문 분석하여 일부 입력 태그 매개 변수 (유형, ID, 이름)를 선택하려고하고 각 데이터 유형이 항목으로 선택됩니다 이 데이터베이스에 그런 나중에 뭔가를 저장할 수 있도록 :정확한 값을 입력 태그에서 추출 .. 이미지 제공
는Database Table_1
╔════════════════╗
║ text ║
╠════════════════╣
║ id │ name ║
╟──────┼─────────╢
║ │ ║
╟──────┼─────────╢
║ │ ║
╚══════╧═════════╝
은 같은, 암호 및 파일 만에
난 그 XPath는 전체 태그를 추출한다 직면 문제가 될 것입니다!
from scrapy.contrib.spiders import CrawlSpider, Rule
from scrapy.contrib.linkextractors.sgml import SgmlLinkExtractor
from scrapy.selector import HtmlXPathSelector
from scrapy.item import Item, Field
from isa.items import IsaItem
class MySpider(CrawlSpider):
name = 'example.com'
allowed_domains = ['testaspnet.vulnweb.com']
start_urls = ['http://testaspnet.vulnweb.com']
rules = (
Rule(SgmlLinkExtractor(allow=('/*')),callback='parse_item'),)
def parse_item(self, response):
self.log('%s' % response.url)
hxs = HtmlXPathSelector(response)
item=IsaItem()
text_input=hxs.select("//input[(@id or @name) and (@type = 'text')]").extract()
pass_input=hxs.select("//input[(@id or @name) and (@type = 'password')]").extract()
file_input=hxs.select("//input[(@id or @name) and (@type = 'file')]").extract()
print text_input , pass_input ,file_input
return item
출력 내가 바로 당신을 이해 한 경우
[email protected]:~/isa/isa$ scrapy crawl example.com -L INFO -o file_nfffame.csv -t csv
2012-07-02 12:42:02+0200 [scrapy] INFO: Scrapy 0.14.4 started (bot: isa)
2012-07-02 12:42:02+0200 [example.com] INFO: Spider opened
2012-07-02 12:42:02+0200 [example.com] INFO: Crawled 0 pages (at 0 pages/min), scraped 0 items (at 0 items/min)
[] [] []
[] [] []
[] [] []
[u'<input name="tbUsername" type="text" id="tbUsername" class="Login">'] [u'<input name="tbPassword" type="password" id="tbPassword" class="Login">'] []
[] [] []
[u'<input name="tbUsername" type="text" id="tbUsername" class="Login">'] [u'<input name="tbPassword" type="password" id="tbPassword" class="Login">'] []
[] [] []
2012-07-02 12:42:08+0200 [example.com] INFO: Closing spider (finished)
올바른 출력은 어떻게 표시되어야합니까? –
@stav 형식의 텍스트 >> [ID, 이름], 정확히 [ "tbUsername", "tbUsername"], [ "tbPassword", "tbPassword"] 유형의 경우 ID가 중복 된 것으로 알고 있습니다. 값이 있지만이 양식은 id = name –