Python / Selenium 仅在 class 具有特定值时打印 + 仅打印 html 中的某些元素

Python / Selenium only print if class has a certain value + only print certain elements in html

我正在编写一个脚本来测试所有可用的免费代理:https://free-proxy-list.net/

在这个网站上有一个包含所有可用代理的列表,我设法让我的脚本打印它们,但是,如果启用了 https,我只想打印代理值。

这是启用 https 时 Html 的外观:

<tr><td>51.222.40.26</td>
<td>9090</td>
<td>CA</td>
<td class="hm">Canada</td>
<td>anonymous</td>
<td class="hm">no</td>
<td class="hx">yes</td>
<td class="hm">13 secs ago</td></tr>

"hx"class设置为yes如何让我的代码只在"hx"[=40时打印代理=] 值为 "yes"?

有没有办法只打印代理而不打印“匿名”或“加拿大”

我的代码:

from selenium import webdriver as wd
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

driver = wd.Chrome('C:/chromedriver.exe')
wait = WebDriverWait(driver, 15)

class Proxy_selector:
    driver.get('https://free-proxy-list.net/')
    print([my_elem.text for my_elem in WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.ID, 'list')))])

if __name__ == "__main__":
    Proxy_selector()

当前输出示例:

['Free Proxy List\nFree proxies that are just checked and updated every 10 minutes\nShare on Facebook\nTweet\nSend email\nPrint\nGet raw list\nIP Address Port Code Country Anonymity Google Https Last Checked\n212.34.1.110 8080 JO Jordan anonymous no yes 1 min ago\n216.176.187.99 39825 US United States elite proxy no yes 1 min ago\n103.133.24.97 8181 ID Indonesia anonymous no no 1 min ago\n187.217.54.84 80 MX Mexico elite proxy no no 1 min ago\n169.57.1.85 8123 MX Mexico elite proxy no yes 1 min ago\n107.151.182.247 80 US United States anonymous no no 1 min ago\n51.222.40.26 9090 CA Canada anonymous no no 1 min ago\n3.136.59.77 80 US United States anonymous no no 1 min ago\n194.5.193.183 80 NL Netherlands anonymous no no 1 min ago\n135.125.4.232 9090 FR France anonymous yes yes 1 min ago\n176.9.75.42 8080 DE Germany anonymous no no 1 min ago\n139.99.237.62 80 AU Australia anonymous no no 1 min ago\n88.198.24.108 8080 DE Germany anonymous no no 1 min ago\n176.31.68.252 20213 FR France elite proxy yes yes 1 min ago\n188.138.106.133 5566 FR France elite proxy no no 1 min ago\n80.48.119.28 8080 PL Poland elite proxy yes no 1 min ago\n134.19.254.2 21231 GE Georgia elite proxy no no 1 min ago\n117.54.114.96 80 ID Indonesia anonymous no no 1 min ago\n152.32.201.77 443 JP Japan elite proxy no no 1 min ago\n82.99.232.18 34415 IR Iran elite proxy no no 1 min ago\n47.245.11.194 80 JP Japan anonymous no no 1 min ago\n47.242.245.107 80 HK Hong Kong anonymous no no 1 min ago\n80.17.254.230 80 IT Italy elite proxy no no 1 min ago\n134.195.101.198 80 US United States anonymous no no 1 min ago\n202.136.165.22 80 SG Singapore anonymous no no 1 min ago\n121.240.20.207 80 IN India elite proxy no no 1 min ago\n85.25.133.28 5566 FR France elite proxy no no 1 min ago\n70.166.215.26 80 US United States anonymous no no 1 min ago\n47.74.34.226 80 JP Japan anonymous no no 1 min ago\n139.28.38.229 80 UA Ukraine anonymous no no 1 min ago\n159.69.58.251 80 DE Germany anonymous yes no 1 min ago\n197.254.97.252 80 KE Kenya anonymous no no 1 min ago\n129.226.127.36 80 HK Hong Kong anonymous no no 1 min ago\n8.214.41.50 80 SG Singapore anonymous no no 1 min ago\n200.116.198.177 35184 CO Colombia elite proxy no no 2 mins ago\n52.169.143.106 8080 IE Ireland elite proxy no no 2 mins ago\n85.25.117.134 5566 FR France elite proxy no no 2 mins ago\n190.61.91.175 8080 CO Colombia transparent no no 7 mins ago\n210.245.54.97 8080 VN Vietnam transparent no no 7 mins ago\n45.6.103.150 8080 BR Brazil transparent no no 8 mins ago\n124.158.161.185 8080 ID Indonesia transparent no no 8 mins ago\n103.14.199.240 84 IN India transparent no no 8 mins ago\n175.197.116.163 59394 KR Korea anonymous yes 10 mins ago\n134.119.217.110 1080 -- Unknown anonymous yes 10 mins ago\n159.65.171.69 80 US United States elite proxy yes no 11 mins ago\n52.230.57.229 80 SG Singapore anonymous no yes 11 mins ago\n191.96.42.80 8080 US United States anonymous no no 11 mins ago\n185.88.37.142 8085 IL Israel transparent no no 11 mins ago\n200.106.187.247 999 AR Argentina transparent no no 13 mins ago\n154.236.179.226 1981 EG Egypt transparent no no 16 mins ago\n182.253.6.236 8080 ID Indonesia transparent no no 16 mins ago\n206.189.143.60 80 IN India transparent no no 16 mins ago\n156.200.110.116 1976 EG Egypt transparent no no 19 mins ago\n138.68.235.51 80 US United States elite proxy no 21 mins ago\n185.88.37.111 8085 IL Israel elite proxy no 21 mins ago\n103.80.1.2 80 BD Bangladesh anonymous no no 21 mins ago\n202.165.47.90 55443 ID Indonesia transparent no no 21 mins ago\n198.11.173.185 80 US United States anonymous no no 21 mins ago\n103.134.97.97 83 IN India transparent no no 24 mins ago\n45.176.169.18 3128 BR Brazil transparent no no 28 mins ago\n103.76.44.82 8080 BD Bangladesh anonymous no 30 mins ago\n85.25.95.117 5566 FR France elite proxy no 30 mins ago\n103.148.72.192 80 HK Hong Kong anonymous yes no 30 mins ago\n74.143.245.221 80 US United States anonymous no no 30 mins ago\n116.100.181.202 8080 VN Vietnam elite proxy no 30 mins ago\n177.223.58.68 54579 BR Brazil elite proxy no 30 mins ago\n209.97.150.167 8080 US United States anonymous no no 30 mins ago\n121.1.41.162 111 PH Philippines elite proxy no no 30 mins ago\n110.232.64.90 8080 ID Indonesia transparent no no 30 mins ago\n51.79.50.31 9300 CA Canada elite proxy no 30 mins ago\n117.54.114.98 80 ID Indonesia anonymous no 30 mins ago\n165.154.92.146 8888 HK Hong Kong anonymous no yes 30 mins ago\n197.254.97.253 80 KE Kenya anonymous no 30 mins ago\n93.99.12.17 8080 CZ Czech Republic elite proxy no 30 mins ago\n85.25.91.161 5566 DE Germany elite proxy no 30 mins ago\n216.137.184.253 80 US United States elite proxy no no 30 mins ago\n197.254.97.254 80 KE Kenya anonymous no no 31 mins ago\n160.119.128.102 21213 GN Guinea elite proxy no no 31 mins ago\n165.22.45.209 8899 US United States elite proxy no no 31 mins ago\n123.231.221.242 6969 ID Indonesia elite proxy no no 31 mins ago\n13.91.104.216 80 US United States elite proxy no no 31 mins ago\n103.105.212.106 53281 PH Philippines elite proxy no no 31 mins ago\n188.138.11.48 5566 FR France elite proxy no no 31 mins ago\n5.181.171.96 8085 RU Russian Federation elite proxy no no 31 mins ago\n66.94.120.161 443 US United States elite proxy no no 31 mins ago\n155.138.132.50 80 CA Canada anonymous no no 31 mins ago\n8.210.83.33 80 HK Hong Kong anonymous no no 31 mins ago\n188.138.89.50 5566 FR France elite proxy no no 31 mins ago\n182.52.112.75 8080 TH Thailand transparent no no 32 mins ago\n51.159.3.223 443 FR France transparent no no 35 mins ago\n36.90.54.253 3127 ID Indonesia transparent no no 35 mins ago\n200.60.118.171 999 PE Peru transparent no no 35 mins ago\n181.78.27.226 999 PY Paraguay transparent no no 35 mins ago\n190.217.14.171 999 VE Venezuela transparent no no 35 mins ago\n94.23.91.209 80 PL Poland elite proxy no no 40 mins ago\n159.203.13.121 80 CA Canada elite proxy no no 40 mins ago\n182.74.183.226 80 IN India elite proxy yes no 40 mins ago\n161.35.4.201 80 US United States elite proxy no no 40 mins ago\n196.20.12.41 8080 NA Namibia transparent no no 40 mins ago\n182.52.236.134 8080 TH Thailand transparent no no 40 mins ago\n181.205.70.146 41890 CO Colombia elite proxy no 41 mins ago\n85.25.208.198 5566 FR France elite proxy no 41 mins ago\n193.34.21.4 55277 UA Ukraine elite proxy no 41 mins ago\n201.249.161.51 999 VE Venezuela anonymous no 41 mins ago\n124.41.240.96 55443 NP Nepal elite proxy no 41 mins ago\n103.73.194.2 80 HK Hong Kong anonymous no 41 mins ago\n149.56.96.252 9300 CA Canada elite proxy no 41 mins ago\n202.21.117.78 8080 MN Mongolia transparent no no 42 mins ago\n195.239.217.102 8080 RU Russian Federation transparent no no 42 mins ago\n2.56.215.247 3128 FR France transparent no no 43 mins ago\n176.235.139.37 10001 TR Turkey transparent no no 46 mins ago\n147.135.134.57 5566 FR France anonymous yes 50 mins ago\n197.254.97.248 80 KE Kenya anonymous no no 50 mins ago\n175.144.112.238 80 MY Malaysia anonymous no no 50 mins ago\n175.144.112.239 80 MY Malaysia anonymous no no 50 mins ago\n128.199.169.3 8888 SG Singapore anonymous no no 51 mins ago\n47.251.5.248 80 US United States anonymous yes no 51 mins ago\n36.92.85.66 8080 ID Indonesia elite proxy no 1 hour ago\n104.248.90.212 80 NL Netherlands elite proxy no 1 hour ago\n117.54.114.99 80 ID Indonesia anonymous no 1 hour ago\n115.75.5.17 38351 VN Vietnam elite proxy no 1 hour ago\n175.144.112.236 80 MY Malaysia anonymous no no 1 hour ago\n203.207.52.206 8085 ID Indonesia elite proxy no 1 hour ago\n160.16.242.164 3128 JP Japan elite proxy no yes 1 hour ago\n200.37.140.35 10101 PE Peru elite proxy no 1 hour ago\n193.41.88.58 53281 UA Ukraine elite proxy no 1 hour ago\n106.0.48.130 8080 ID Indonesia anonymous no yes 1 hour 1 min ago\n187.62.67.166 45005 BR Brazil transparent no no 1 hour 1 min ago\n93.99.12.30 8080 CZ Czech Republic elite proxy no 1 hour 1 min ago\n188.72.6.98 37083 IQ Iraq elite proxy no 1 hour 1 min ago\n128.0.179.234 41258 CZ Czech Republic elite proxy no 1 hour 1 min ago\n165.154.225.106 80 HK Hong Kong anonymous no no 1 hour 1 min ago\n46.175.70.69 44239 UA Ukraine elite proxy no 1 hour 1 min ago\n117.54.114.101 80 ID Indonesia anonymous no no 1 hour 1 min ago\n128.199.202.122 8080 SG Singapore anonymous no 1 hour 1 min ago\n94.181.48.95 1256 RU Russian Federation transparent no no 1 hour 2 mins ago\n129.153.133.203 3128 US United States transparent no no 1 hour 2 mins ago\n134.209.42.113 8899 US United States elite proxy no 1 hour 2 mins ago\n88.119.195.35 8080 LT Lithuania elite proxy no no 1 hour 2 mins ago\n85.25.119.98 5566 FR France elite proxy no 1 hour 2 mins ago\n95.217.84.60 8118 FI Finland elite proxy no 1 hour 2 mins ago\n77.238.79.111 8080 BG Bulgaria elite proxy no 1 hour 2 mins ago\n167.172.178.193 43807 DE Germany elite proxy no 1 hour 2 mins ago\n45.122.233.76 55443 VN Vietnam elite proxy no 1 hour 2 mins ago\n187.44.167.78 60786 BR Brazil elite proxy no 1 hour 2 mins ago\n115.241.197.126 80 IN India anonymous no 1 hour 2 mins ago\n212.115.232.79 31280 UA Ukraine elite proxy no 1 hour 2 mins ago\n103.216.82.22 6666 IN India elite proxy no 1 hour 2 mins ago\n117.54.114.102 80 ID Indonesia anonymous no 1 hour 2 mins ago\n193.193.240.37 45944 KZ Kazakhstan elite proxy no 1 hour 2 mins ago\n154.236.184.70 1976 EG Egypt anonymous no 1 hour 2 mins ago\n103.162.205.51 8181 ID Indonesia elite proxy no 1 hour 2 mins ago\n176.36.20.67 61935 UA Ukraine elite proxy no 1 hour 2 mins ago\n85.195.86.231 1080 DE Germany elite proxy no 1 hour 2 mins ago\n213.139.32.14 8080 JO Jordan anonymous no 1 hour 2 mins ago\n62.33.136.222 8080 RU Russian Federation transparent no no 1 hour 2 mins ago\n103.161.164.103 8181 ID Indonesia transparent no no 1 hour 2 mins ago\n85.25.119.113 5566 FR France elite proxy no 1 hour 2 mins ago\n78.37.24.148 8080 RU Russian Federation elite proxy no 1 hour 2 mins ago\n203.154.39.146 80 TH Thailand elite proxy no 1 hour 2 mins ago\n103.130.141.98 8080 KH Cambodia elite proxy no 1 hour 2 mins ago\n51.178.195.49 8080 FR France elite proxy no 1 hour 2 mins ago\n85.25.201.22 5566 FR France elite proxy no 1 hour 2 mins ago\n85.25.100.47 5566 FR France elite proxy no no 1 hour 2 mins ago\n88.132.95.93 53281 HU Hungary elite proxy no 1 hour 2 mins ago\n37.61.222.172 1080 DE Germany elite proxy no 1 hour 2 mins ago\n200.105.215.18 33630 BO Bolivia elite proxy no 1 hour 2 mins ago\n5.160.101.170 3128 IR Iran elite proxy no yes 1 hour 2 mins ago\n79.143.87.138 9090 GB United Kingdom anonymous no yes 1 hour 3 mins ago\n185.17.132.15 2536 RU Russian Federation elite proxy no yes 1 hour 3 mins ago\n103.251.214.167 6666 IN India elite proxy yes 1 hour 3 mins ago\n190.122.185.170 999 GT Guatemala elite proxy no 1 hour 3 mins ago\n41.164.68.194 8080 ZA South Africa elite proxy no 1 hour 3 mins ago\n119.235.17.105 55443 ID Indonesia elite proxy yes 1 hour 3 mins ago\n85.195.86.227 1080 DE Germany elite proxy no yes 1 hour 4 mins ago\n43.255.113.232 8082 KH Cambodia elite proxy no 1 hour 5 mins ago\n85.25.235.229 5566 FR France elite proxy no 1 hour 5 mins ago\n173.82.149.243 8080 US United States anonymous no no 1 hour 5 mins ago\n103.103.212.222 53281 IN India elite proxy no yes 1 hour 5 mins ago\n85.25.108.234 5566 FR France elite proxy no yes 1 hour 5 mins ago\n103.158.121.79 8080 ID Indonesia anonymous yes yes 1 hour 6 mins ago\n45.156.184.131 8080 IR Iran elite proxy no no 1 hour 6 mins ago\n37.61.220.236 1080 DE Germany anonymous yes yes 1 hour 6 mins ago\n85.25.199.50 5566 FR France elite proxy no yes 1 hour 6 mins ago\n78.30.230.117 50932 UA Ukraine elite proxy no no 1 hour 6 mins ago\n168.90.14.162 999 CO Colombia transparent no no 1 hour 7 mins ago\n81.1.26.102 8080 FR France anonymous no yes 1 hour 10 mins ago\n165.139.238.20 8080 US United States anonymous no yes 1 hour 10 mins ago\n116.203.151.201 8080 DE Germany elite proxy no no 1 hour 11 mins ago\n174.129.129.98 80 US United States elite proxy no no 1 hour 11 mins ago\n146.59.199.12 80 FR France elite proxy no no 1 hour 11 mins ago\n159.65.205.98 3128 NL Netherlands transparent no no 1 hour 11 mins ago\n195.154.243.54 80 FR France elite proxy no no 1 hour 11 mins ago\n157.230.233.189 3005 US United States transparent no no 1 hour 11 mins ago\n161.49.212.173 1337 PH Philippines transparent no no 1 hour 13 mins ago\n27.72.147.22 40009 VN Vietnam transparent no no 1 hour 13 mins ago\n103.84.234.250 63123 ID Indonesia transparent no no 1 hour 18 mins ago\n41.65.162.75 1981 EG Egypt transparent no no 1 hour 18 mins ago\n119.93.129.34 80 PH Philippines transparent no no 1 hour 18 mins ago\n176.119.159.63 1080 RU Russian Federation transparent no no 1 hour 20 mins ago\n85.25.199.122 5566 FR France elite proxy no 1 hour 20 mins ago\n158.69.52.218 9300 CA Canada elite proxy no 1 hour 20 mins ago\n78.128.124.9 50246 BG Bulgaria elite proxy no 1 hour 20 mins ago\n213.232.123.209 8085 RU Russian Federation elite proxy no 1 hour 20 mins ago\n47.245.12.42 80 JP Japan anonymous no 1 hour 20 mins ago\n45.15.142.122 3128 US United States elite proxy no yes 1 hour 20 mins ago\n197.254.97.255 80 KE Kenya anonymous no 1 hour 21 mins ago\n213.230.90.106 3128 UZ Uzbekistan elite proxy no 1 hour 21 mins ago\n178.216.24.80 55443 PL Poland elite proxy no 1 hour 21 mins ago\n110.74.198.175 56765 KH Cambodia elite proxy no 1 hour 21 mins ago\n120.89.90.210 8181 ID Indonesia elite proxy no 1 hour 21 mins ago\n5.181.171.183 8085 RU Russian Federation elite proxy no 1 hour 21 mins ago\n213.232.123.249 8085 RU Russian Federation elite proxy no 1 hour 21 mins ago\n195.182.133.107 3128 RU Russian Federation elite proxy no 1 hour 21 mins ago\n14.207.122.162 8080 TH Thailand elite proxy no 1 hour 21 mins ago\n176.214.46.116 8080 RU Russian Federation elite proxy no 1 hour 21 mins ago\n103.206.128.1 7532 IN India elite proxy no 1 hour 21 mins ago\n191.242.230.135 8080 BR Brazil transparent no no 1 hour 23 mins ago\n103.114.52.2 8080 ID Indonesia transparent no no 1 hour 24 mins ago\n77.235.134.78 8080 LB Lebanon transparent no no 1 hour 28 mins ago\n41.65.224.94 1976 EG Egypt transparent no no 1 hour 28 mins ago\n41.128.148.77 1976 EG Egypt transparent no no 1 hour 28 mins ago\n13.233.95.96 80 IN India transparent no no 1 hour 30 mins ago\n3.6.248.59 80 IN India transparent no no 1 hour 30 mins ago\n189.11.248.162 8080 BR Brazil transparent no no 1 hour 30 mins ago\n68.183.81.71 80 IN India transparent no no 1 hour 30 mins ago\n124.40.244.137 8080 IN India transparent no no 1 hour 30 mins ago\n139.59.7.208 80 IN India transparent no no 1 hour 30 mins ago\n151.232.72.14 80 IR Iran transparent no no 1 hour 30 mins ago\n13.126.212.108 80 IN India transparent no no 1 hour 30 mins ago\n110.49.11.50 8080 TH Thailand transparent no no 1 hour 30 mins ago\n157.245.113.148 80 US United States transparent no no 1 hour 30 mins ago\n178.128.78.109 80 US United States transparent no no 1 hour 30 mins ago\n172.105.41.168 80 IN India transparent no no 1 hour 30 mins ago\n13.114.162.45 80 JP Japan transparent no no 1 hour 30 mins ago\n151.232.72.13 80 IR Iran transparent no no 1 hour 30 mins ago\n68.183.80.246 80 IN India transparent no no 1 hour 30 mins ago\n151.232.72.16 80 IR Iran transparent no no 1 hour 30 mins ago\n151.232.72.15 80 IR Iran transparent no no 1 hour 30 mins ago\n151.232.72.12 80 IR Iran transparent no no 1 hour 30 mins ago\n172.105.80.234 80 DE Germany transparent no no 1 hour 30 mins ago\n104.248.83.79 80 NL Netherlands transparent no no 1 hour 30 mins ago\n41.65.251.84 1981 EG Egypt transparent no no 1 hour 30 mins ago\n172.104.52.33 80 SG Singapore transparent no no 1 hour 30 mins ago\n178.128.84.209 80 SG Singapore transparent no no 1 hour 30 mins ago\n178.128.146.76 80 US United States transparent no no 1 hour 30 mins ago\n167.71.83.186 80 US United States transparent no no 1 hour 30 mins ago\n177.73.112.60 9090 BR Brazil transparent no no 1 hour 30 mins ago\n45.224.153.39 999 EC Ecuador transparent no no 1 hour 30 mins ago\n197.254.97.250 80 KE Kenya anonymous no no 1 hour 30 mins ago\n150.109.32.166 80 HK Hong Kong anonymous no 1 hour 30 mins ago\n181.48.91.91 999 CO Colombia transparent no no 1 hour 31 mins ago\n221.120.123.141 80 SG Singapore transparent no no 1 hour 31 mins ago\n37.44.254.208 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n31.40.252.251 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n139.99.105.186 80 SG Singapore transparent no no 1 hour 31 mins ago\n216.115.8.148 80 US United States transparent no no 1 hour 31 mins ago\n37.44.254.174 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.10.165.128 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n85.239.57.39 8085 US United States transparent no no 1 hour 31 mins ago\n193.233.143.246 8085 US United States transparent no no 1 hour 31 mins ago\n45.80.107.102 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.67.214.159 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.145.131.195 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n91.242.228.36 8085 US United States transparent no no 1 hour 31 mins ago\n85.209.149.219 8085 US United States transparent no no 1 hour 31 mins ago\n75.254.97.227 80 US United States transparent no no 1 hour 31 mins ago\n132.148.85.91 80 US United States transparent no no 1 hour 31 mins ago\n153.120.25.103 80 JP Japan transparent no no 1 hour 31 mins ago\n84.33.2.24 80 IT Italy transparent no no 1 hour 31 mins ago\n88.218.67.84 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n213.85.92.10 80 RU Russian Federation transparent no no 1 hour 31 mins ago\n77.83.85.40 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.67.212.55 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n194.104.9.92 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.67.214.81 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n156.154.112.240 80 US United States transparent no no 1 hour 31 mins ago\n197.243.20.178 80 RW Rwanda transparent no no 1 hour 31 mins ago\n101.44.1.22 80 SG Singapore transparent no no 1 hour 31 mins ago\n101.44.1.23 80 SG Singapore transparent no no 1 hour 31 mins ago\n193.56.64.195 8085 US United States transparent no no 1 hour 31 mins ago\n50.206.25.111 80 US United States transparent no no 1 hour 31 mins ago\n23.108.75.62 8118 US United States transparent no no 1 hour 31 mins ago\n193.233.82.43 8085 US United States transparent no no 1 hour 31 mins ago\n63.217.44.109 80 US United States transparent no no 1 hour 31 mins ago\n213.166.79.23 8085 US United States transparent no no 1 hour 31 mins ago\n103.214.109.70 80 US United States transparent no no 1 hour 31 mins ago\n91.188.246.181 8085 US United States transparent no no 1 hour 31 mins ago\n209.141.56.127 80 US United States transparent no no 1 hour 31 mins ago\n213.232.121.114 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n95.229.53.197 80 IT Italy transparent no no 1 hour 31 mins ago\n60.32.214.122 80 JP Japan transparent no no 1 hour 31 mins ago\n193.56.20.210 8085 MX Mexico transparent no no 1 hour 31 mins ago\n64.227.76.157 38506 NL Netherlands transparent no no 1 hour 31 mins ago\n62.45.66.92 80 NL Netherlands transparent no no 1 hour 31 mins ago\n190.120.238.103 80 PA Panama transparent no no 1 hour 31 mins ago\n86.122.124.11 80 RO Romania transparent no no 1 hour 31 mins ago\n45.138.101.31 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n85.208.85.172 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\n45.145.131.249 8085 RU Russian Federation transparent no no 1 hour 31 mins ago\nBUY PREMIUM PROXY   SAVE TIME  ']

感谢您的帮助

你可以使用 xpath //td[@class='hx' and text()='yes']/.. 过滤它,这个 xpath 只会检查 class hxtext()='yes'

代码:

driver.get('https://free-proxy-list.net/')

print([my_elem.text for my_elem in WebDriverWait(driver, 20).until(EC.presence_of_all_elements_located((By.XPATH, "//td[@class='hx' and text()='yes']/..")))])

进口:

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC

输出:

['165.22.45.209 8899 US United States elite proxy yes yes 1 min ago', '202.136.165.22 80 SG Singapore anonymous no yes 1 min ago', '120.89.90.210 8181 ID Indonesia elite proxy no yes 1 min ago', '169.57.1.85 8123 MX Mexico elite proxy no yes 1 min ago', '51.222.40.26 9090 CA Canada anonymous no yes 1 min ago', '176.31.68.252 20213 FR France elite proxy yes yes 1 min ago', '8.214.41.50 80 SG Singapore anonymous no yes 1 min ago', '121.240.20.207 80 IN India elite proxy no yes 10 mins ago', '14.207.122.162 8080 TH Thailand elite proxy no yes 10 mins ago', '103.151.140.165 8080 ID Indonesia anonymous no yes 20 mins ago', '91.231.233.124 11712 RU Russian Federation elite proxy no yes 20 mins ago', '52.230.57.229 80 SG Singapore anonymous no yes 20 mins ago', '216.176.187.99 39825 US United States elite proxy yes yes 20 mins ago', '154.236.184.74 1976 EG Egypt anonymous no yes 21 mins ago', '167.172.178.193 43807 DE Germany elite proxy no yes 22 mins ago', '49.12.43.32 5555 DE Germany anonymous no yes 31 mins ago', '51.79.50.46 5566 CA Canada elite proxy no yes 31 mins ago', '175.197.116.163 59394 KR Korea anonymous yes 50 mins ago', '134.119.217.110 1080 -- Unknown anonymous yes 50 mins ago', '165.154.92.146 8888 HK Hong Kong anonymous no yes 1 hour 10 mins ago', '147.135.134.57 5566 FR France anonymous yes 1 hour 30 mins ago', '160.16.242.164 3128 JP Japan elite proxy no yes 1 hour 40 mins ago', '106.0.48.130 8080 ID Indonesia anonymous no yes 1 hour 41 mins ago', '5.160.101.170 3128 IR Iran elite proxy no yes 1 hour 42 mins ago', '79.143.87.138 9090 GB United Kingdom anonymous no yes 1 hour 43 mins ago', '185.17.132.15 2536 RU Russian Federation elite proxy no yes 1 hour 43 mins ago', '103.251.214.167 6666 IN India elite proxy yes 1 hour 43 mins ago', '119.235.17.105 55443 ID Indonesia elite proxy yes 1 hour 43 mins ago', '85.195.86.227 1080 DE Germany elite proxy no yes 1 hour 44 mins ago', '103.103.212.222 53281 IN India elite proxy no yes 1 hour 45 mins ago', '85.25.108.234 5566 FR France elite proxy no yes 1 hour 45 mins ago', '103.158.121.79 8080 ID Indonesia anonymous yes yes 1 hour 46 mins ago', '37.61.220.236 1080 DE Germany anonymous yes yes 1 hour 46 mins ago', '85.25.199.50 5566 FR France elite proxy no yes 1 hour 46 mins ago', '81.1.26.102 8080 FR France anonymous no yes 1 hour 50 mins ago', '165.139.238.20 8080 US United States anonymous no yes 1 hour 50 mins ago', '45.15.142.122 3128 US United States elite proxy no yes 2 hours ago']

Process finished with exit code 0