本帖最后由 luck 于 2018-2-28 09:38 编辑 , r g0 ~: [5 } V4 ]! V q
! ^' e! }$ { M
刚才我己安装python,然后进 行了以下步骤- z8 u: q6 \7 Q' R& G
附件>运行>CMD 打开了cmd窗口,输入pip install requests ,如下图 / q6 ?; ?7 ^" l8 V# n7 x, S' V
. b( O+ `- |% [9 r P' T然后呢,怎么办,把下面这段代码放到上面的窗口中吗?. h, ~6 c4 B! O; a' K8 s0 B2 a
import requests
# `6 S/ q7 c) P" P# ~# r! _headers = {"user-agent": "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.86 Safari/537.36" }
3 k' i8 b# \ Z T& G: k# u" Lurl = "https://www.aliexpress.com/category/5090301/mobile-phones.html"
, n0 t% u3 W& q. \# ^0 u& bresponse = requests.get(url, headers=headers)5 P: C0 h. G6 U9 D4 H0 |
html = etree.HTML(response.content) j0 p. v$ B# k6 `* F
print(response.text)
* D! O: c& `5 @6 Ubtlist= html.xpath(".//h3[@class='icon-hotproduct']/a/@title"), j. w5 q/ s" O/ [, h
for title in btlist: N/ O9 q- F% r* ]9 {- }$ ?- r- m
print(title) 这是输入后的结果 0 f9 e y4 B; \' z0 N
) q% X, |- t5 z& W5 ]怎么办?" _1 d5 D0 u" c- l0 H, m
原谅我太笨了,谢谢! 4 n3 L) ` t+ I7 \" B* p
. N4 w5 a2 X- L8 T4 T8 F7 q0 S
8 T; |6 @& d/ L; I1 b |