2017-04-03 2 views
0

wie Schrott Text von <a>

<div id="job_14" class="job"> 
 
    <a target="_blank" href="https://www.indeed.com/viewjob?t=Associate+Network+System&amp;c=Las+Vegas+Valley+Water+District&amp;l=Las+Vegas%2C+NV&amp;jk=a22e9d1fa81cae52&amp;indpubnum=4385896808151888&amp;atk=&amp;chnl=JobrollSearch" class="jobtitle" rel="nofollow">Associate Network

wie Schrott Text von

Antwort

0

Sie mit CSS-Selektor versuchen:

response.css('.job a::text') 

Welche Knoten mit Klasse auszuwählen übersetzt job -> wählen Unterknoten <a> -> Wählen Sie text Wert des aktuellen Knotens.

0

Sie können auch mit XPath versuchen. Der CSS-Selektor wird in xpath übersetzt und dann ausgeführt.

my_xpath = "//div[@id='job_14']/a" 
my_text = tree.xpath(my_xpath) 
my_text = my_text.text