I'm doing some scraping of a page and I'm fine with getting most fields, but having some problems with the开发者_StackOverflow中文版 address.
<address>
56 South Ave
<br>
Miami, FL 33131
<br>
</address>
address = myWebPage.xpath("//div[contains(@class,'rightcol')]//address")
I can get the first line, 56 South Avenue, using the above code. But I can't get the city, state, zip. How would I change the code to get the full address?
//div[contains(@class,'rightcol')]//address/text()[1]
selects the first text-node child of address
:
"
56 South Ave
"
//div[contains(@class,'rightcol')]//address/text()[2]
selects the second text-node child of address
:
"
Miami, FL 33131
"
//div[contains(@class,'rightcol')]//address/text()
selects both text-node children of address
.
精彩评论