本帖最后由 luck 于 2018-2-28 09:38 编辑
0 l1 ]2 o, s ~# b2 n A. F$ ^: ~" v+ o8 ]7 H# D2 D9 z
刚才我己安装python,然后进 行了以下步骤
3 t4 ~1 \7 C! b# D- A7 O- i# y附件>运行>CMD 打开了cmd窗口,输入pip install requests ,如下图 / E- v& H7 i: [3 c7 D
7 q, O0 D4 ]7 E2 ~6 c+ g然后呢,怎么办,把下面这段代码放到上面的窗口中吗?
( y& ^/ r( G, g import requests6 M1 h5 h* }& d8 H
headers = {"user-agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36" }
7 y7 a9 a. c3 I+ `$ u7 N. i zurl = "https://www.aliexpress.com/category/5090301/mobile-phones.html"- f( E8 n4 v* s# ~( J
response = requests.get(url, headers=headers): E& j+ y5 t. k) [
html = etree.HTML(response.content)
5 Q- y6 t) ?) i# I" rprint(response.text)) Q z4 J9 B4 N+ N: V
btlist= html.xpath(".//h3[@class='icon-hotproduct']/a/@title")
U* ~( l9 C9 `9 ]- Lfor title in btlist:
5 U5 K/ V. n x6 }3 W print(title) 这是输入后的结果
2 x: K3 I( p- B' u8 U
3 Q& q/ W7 n/ @6 G/ o怎么办?
' l/ r! t/ M- t4 s( c 原谅我太笨了,谢谢!
% n- d! N8 c6 @; T' g1 C9 n/ h4 O, O o& {' O) y- f. @) S' P; C
0 A6 [# L) _4 {, O' |7 K |