String Match=""(https://www.tianyancha.com/company/d+)" target='_blank'";
Pattern pattern=Pattern.compile(Match);
Headers.put("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36");
Response=HttpGet("https://www.tianyancha.com/search?key=%E5%8C%97%E4%BA%AC%E7%AB%8B%E7%BA%A2%E9%A4%90%E9%A5%AE%E7%AE%A1%E7%90%86%E6%9C%89%E9%99%90%E5%85%AC%E5%8F%B8",Headers);
Matcher MatcherUrl=pattern.matcher(Response);
if(MatcherUrl.find()) {
System.out.println("打印匹配数据");
System.out.println(MatcherUrl.group(0));
}
结果是
打印匹配数据
"https://www.tianyancha.com/company/4079618929" target='_blank'
我想要的其实就是
https://www.tianyancha.com/company/4079618929
如何不改变Pattern 只匹配其中的部分内容呢?
python 里面只要大括号就能匹配 括号里面的内容
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…