ちょうどScrapyを使い始めると、私は正しい方向への動きを望んでいます。実行中の結果
私はここからデータをこすりしたい:、
import scrapy
import re
class BlogSpider(scrapy.Spider):
name = 'sportstats'
start_urls = ['https://www.sportstats.ca/display-results.xhtml?raceid=29360']
def parse(self, response):
headings = []
results = []
tables = response.xpath('//table')
headings = list(tables[0].xpath('thead/tr/th/span/span/text()').extract())
rows = tables[0].xpath('tbody/tr[contains(@class, "ui-widget-content ui-datatable")]')
for row in rows:
result = []
tds = row.xpath('td')
for td in enumerate(tds):
if headings[td[0]].lower() == 'comp.':
content = None
elif headings[td[0]].lower() == 'view':
content = None
elif headings[td[0]].lower() == 'name':
content = td[1].xpath('span/a/text()').extract()[0]
else:
try:
content = td[1].xpath('span/text()').extract()[0]
except:
content = None
result.append(content)
results.append(result)
for result in results:
print(result)
は今、私は次のページに移動する必要があり、私は次のことができます。これは私がこれまでにしたものである
https://www.sportstats.ca/display-results.xhtml?raceid=29360
下の "右矢印"をクリックしてブラウザで行います。これは次のようなものです:
<li><a id="mainForm:j_idt369" href="#" class="ui-commandlink ui-widget fa fa-angle-right" onclick="PrimeFaces.ab({s:"mainForm:j_idt369",p:"mainForm",u:"mainForm:result_table mainForm:pageNav mainForm:eventAthleteDetailsDialog",onco:function(xhr,status,args){hideDetails('athlete-popup');showDetails('event-popup');scrollToTopOfElement('mainForm\\:result_table');;}});return false;"></a>
どのようにそれに従うために傷病を得ることができますか?
現在の進捗状況をメインポストに追加しました。 – user3449833
これはJavaScriptのレンダリングの問題です。firefoxを使用してリクエストを確認したり、[Splash](https://github.com/scrapinghub/splash)のようなjavascriptレンダリングサービスを使用して終了した場合は、またはセレン。 – eLRuLL