如何以编程方式访问 Google 的搜索引擎结果并使用 Autohotkey 获得第一个 URL?
How can I access Google's search engine results programmatically and get the first URL with Autohotkey?
我想以编程方式访问 Google 的搜索引擎结果,并使用 Autohotkey 获得第一个 URL。
我可以访问 google 视频搜索页面,但我不知道如何解析第一个视频 URL。
Send ^c
if !Html := UrlGet("https://www.google.com/search?tbm=vid&hl=en-TR&source=hp&biw=&bih=&q=%clipboard%") {
MsgBox No data returned from Google.com
return
}
最简单的方法是使用 regex。
添加到您的代码中:
RegExMatch(Html, "O)<h3 class=""r""><a href=""([^""]+)""", m)
MsgBox, % "The first result is: " m.1
您可能希望根据您的特定需求进一步定制上述正则表达式模式。
我想以编程方式访问 Google 的搜索引擎结果,并使用 Autohotkey 获得第一个 URL。
我可以访问 google 视频搜索页面,但我不知道如何解析第一个视频 URL。
Send ^c
if !Html := UrlGet("https://www.google.com/search?tbm=vid&hl=en-TR&source=hp&biw=&bih=&q=%clipboard%") {
MsgBox No data returned from Google.com
return
}
最简单的方法是使用 regex。
添加到您的代码中:
RegExMatch(Html, "O)<h3 class=""r""><a href=""([^""]+)""", m)
MsgBox, % "The first result is: " m.1
您可能希望根据您的特定需求进一步定制上述正则表达式模式。