如何刮取定位对象?

2024-09-29 22:03:24 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个网址的列表,并想为他们的每个网页刮位置对象。我所指的数据是通过键入窗口位置“进入浏览器控制台。例如,对执行此操作www.github.com网站使用Chrome可以得到如下输出:

Location {assign: function, replace: function, reload: function, ancestorOrigins: DOMStringList, origin: "https://github.com"…}

展开后,您可以看到更多信息:

Location {
    ancestorOrigins: DOMStringList 
    assign: function () { [native code] } 
    hash: "" 
    host: "github.com" 
    hostname: "github.com" 
    href: "https://github.com/" 
    origin: "https://github.com" 
    pathname: "/" 
    port: "" 
    protocol: "https:" 
    reload: function () { [native code] } 
    replace: function () { [native code] } 
    search: "" 
    toString: function toString() { [native code] } 
    valueOf: function valueOf() { [native code] } 
    __proto__: Location  
}

我过去曾使用Python和Mechanize库进行过清理,但直到现在我才想要这个功能,也不知道如何继续。欢迎提出任何建议。在


Tags: httpsgithubcomcodefunctionlocationoriginreload
1条回答
网友
1楼 · 发布于 2024-09-29 22:03:24

据我所知,您需要对所需的web页面执行JavaScript调用。我的建议是使用一些无头浏览器。我对名为PyQt4的框架做了类似的事情。您还可以使用其他无头web浏览器,如PhantomJS。或者您也可能对名为Selenium的工具感兴趣。在

相关问题 更多 >

    热门问题