2018年12月13日 星期四

Scrapy框架css選擇器

# 只有匹配到一個,然後吐出第一個
response.css('table td:nth-child(3) tr:nth-child(2) td:nth-child(1)::text').extract_first('')

# 匹配到多個,變成list方式輸出
result = response.css('table tbody tbody tr:nth-child(2) td:nth-child(3) b font::text').extract()
# 取值
for x in result



另外附上BeautifulSoup的css選擇器參照語法
https://www.w3schools.com/csSref/css_selectors.asp

2018年12月12日 星期三

Python安裝設定環境語法

pip freeze -p Pipfile
pip install
or pip install --dev