[
'How do I merge two dictionaries in a single expression in Python (taking union of dictionaries)?',
'How to call an external command?',
'What are metaclasses in Python?',
'Does Python have a ternary conditional operator?',
'How do you remove duplicates from a list whilst preserving order?',
'Convert bytes to a string',
'How to get line count of a large file cheaply in Python?',
"Does Python have a string 'contains' substring method?",
'Why is “1000000000000000 in range(1000000000000001)” so fast in Python 3?'
]
抓取相似结果 4 _, G9 n$ n3 W* f" L 当你还想获取stackoverflow上其他页面中所有相关的文章标题,则可以直接通过get_result_similar方法获取: # U! `/ M5 P- C4 R i
两个页面的抓取结果为:: o8 W+ n* p4 I A9 O # r$ H7 ~) P' X& n) l3 M6 _抓取确切结果* i) S) {1 |. {8 x3 f# c) l9 N
当你只想抓取某个确切的结果,可以使用get_result_exact方法,即从wanted_list中以完全相同的顺序检索数据:+ s! Z V! Z8 _9 f
比如抓取页面中排第2的相关文章标题,执行结果:" z, {- i e. P9 e
- G+ h" L0 L+ e Z2 u! ^' |
自定义请求模块参数* U0 B) N" J; {, w6 g) [( ?+ u
你还可以传递任何自定义请求模块参数。例如,你可能想使用代理或自定义头:1 `0 [! C" J' h; E