xpath html合并列 [英] xpath html combine columns

查看:290
本文介绍了xpath html合并列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用网站表中的IP和端口从socks-proxy.net提取数据.

I'm trying to extract data from socks-proxy.net with the IP and port from the website table.

我正在linux中使用这些命令来获取IP和端口.如何结合主题?

I'm using these commands in linux to get the IP and port. How can I combine theme?

wget -q -O - "https://socks-proxy.net" | xmllint --html --xpath "//table[@id=\"proxylisttable\"]//tr//td[1]//text()" - 2>/dev/null

输出:

103.254.12.3393.12.55.94192:12:44:11 

它结合了IP,但效果不佳

It combines the IP and it its not good

这将从网站表中获取所有IP

that will get all the IP's from the website table

wget -q -O - "https://socks-proxy.net" | xmllint --html --xpath "//table[@id=\"proxylisttable\"]//tr//td[2]//text()" - 2>/dev/null

将获得所有端口

输出:

108025951082

它结合了端口及其缺点.

It combines the port and its not good.

问题:如何将它们与所需的示例输出结合起来

Question: how can I combine them with the desired example output:

103.254.12.33:1080
93.12.55.94:2595
192:12:44:11:1082

以此类推...

推荐答案

有点晚了,但是看到您正在使用4(!)个不同的工具来完成如此简单的事情,我只得跳进来向您展示另一个令人惊叹的XML.解析器,称为 Xidel ,它可以自己完成所有操作:

A bit late, but seeing you're using 4(!) different tools to accomplish something so simple I just had to jump in to show you another amazing XML parser, called Xidel, which can do it all by itself:

xidel -s https://pastebin.com/raw/F14VRNBc -e '//table[@id="proxylisttable"]/tbody/tr/concat("my",td[5],"://",td[1],":",td[2])'
mySocks4://103.254.126.130:1080
mySocks5://192.228.194.87:25950
mySocks5://173.162.95.122:62168
mySocks4://183.166.22.194:1080
mySocks5://70.44.216.252:40656
[...]

这篇关于xpath html合并列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆