我是scrapy
和XPath
的新手,但在Python中進行了一段時間的編程。我想從頁面https://www.germanystartupjobs.com/job/joblift-berlin-germany-3-working-student-offpage-seo-french-market/
使用scrapy獲得email
,name of the person making the offer
和phone
號碼。如您所見,電子郵件和電話是以<p>
標籤內的文本形式提供的,因此很難提取。如何使用scrapy獲取職位描述?
我的想法是先把文本中的所有文本談論這個各自工作的Job Overview
內或至少和使用ReGex
得到email
,phone number
,如果可能的name of the person
。
所以,我用scrapy shell https://www.germanystartupjobs.com/job/joblift-berlin-germany-3-working-student-offpage-seo-french-market/
命令激發了scrapy shell
,並從那裏得到response
。
現在,我嘗試從div job_description
中獲取所有文本,但實際上我什麼都沒有。我用
full_des = response.xpath('//div[@class="job_description"]/text()').extract()
返回[u'\t\t\t\n\t\t ']
我如何獲得所有從網頁中的文字提到?顯然,這個任務會在之後得到前面提到的屬性,但首先要做的是第一件事。
更新:此選項僅返回[]
response.xpath('//div[@class="job_description"]/div[@class="container"]/div[@class="row"]/text()').extract()
[@類=「job_description」]你立刻去的div [@類=「容器」],讓你跳過了一個元素稱爲「部分」。你可以在xpath查詢中使用它,或者使用//,例如div [@ class =「job_description」] // div [@ class =「container」]/..... – Borna