0
我是新來的scrapping和scrapy,並且我停留在從html頁面檢索部分數據的語法上。我需要從下面的示例代碼中的價格信息:Scrapy XPath語法從字符串中提取部分數據
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="google-play-app" content="app-id=com.move.realtor">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="theme-color" content="#d92228">
<meta name="description" content="View 2 photos of this 0 bed, 1 bath, 227 Sq. Ft. condo/townhome/row home/co-op at 4130 Collins Ave Unit 708, Miami Beach, FL 33140 on sale now for $160,000."/>
我需要提取16萬
我明白瞭如何提取整個字符串,但我停留在如何提取後的價格信息美元符號。
def parse(self, response):
#hxs = HtmlXPathSelector(response)
#sites = hxs.select('//div/li/div/a/@href')
sites = response.xpath('//head')
items = []
for site in sites:
item = RealtorItem()
item['description'] = site.xpath('meta[@name="description"]/@content').extract()
此代碼提取整個字符串,並將其放置在項目,我想我不得不分割字符串,只有存儲的美元符號後的信息?我可以使用正則表達式嗎?有沒有更好的辦法 ?