-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Expand file tree
/
Copy pathkxdaili.py
More file actions
40 lines (33 loc) · 1.17 KB
/
Copy pathkxdaili.py
File metadata and controls
40 lines (33 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# -*- coding: utf-8 -*-
"""
-------------------------------------------------
File Name: kxdaili.py
Description : 开心代理代理源
Author : JHao
date: 2026/5/31
-------------------------------------------------
Change Activity:
2026/05/31:
-------------------------------------------------
"""
__author__ = 'JHao'
from fetcher.baseFetcher import BaseFetcher
from util.webRequest import WebRequest
class KxdailiFetcher(BaseFetcher):
"""开心代理 http://www.kxdaili.com/"""
name = "kxdaili"
url = "http://www.kxdaili.com/dailiip.html"
def fetch(self):
target_urls = [
"http://www.kxdaili.com/dailiip.html",
"http://www.kxdaili.com/dailiip/2/1.html",
]
for url in target_urls:
tree = WebRequest().get(url).tree
for tr in tree.xpath("//table[@class='active']//tr")[1:]:
ip = "".join(tr.xpath('./td[1]/text()')).strip()
port = "".join(tr.xpath('./td[2]/text()')).strip()
yield "%s:%s" % (ip, port)
if __name__ == '__main__':
for proxy in KxdailiFetcher().fetch():
print(proxy)