开发者

Grab content from another website [duplicate]

开发者 https://www.devze.com 2023-01-05 18:10 出处:网络
This question already has answers here: Closed 9 years a开发者_运维知识库go. Possible Duplicate:
This question already has answers here: Closed 9 years a开发者_运维知识库go.

Possible Duplicate:

How to parse and process HTML/XML with PHP?

I want to grab anything thats inside the code below on a website.

<table class="eventResults byEvent vevent"></table>

How can I accomplish this? Thanks


If you want to grab HTML from a site, you will want to use a DOM Parser. PHP has several XML processing packages to help you with this, be it DOM, SimpleXML or XMLReader. An often suggested alternative at SO is SimpleHtmlDom.

Since one of the class in the table is vevent, the content inside the table could be an hCalender microformat (can't tell for sure without seeing the content). If so, you can also use a microformat parser, preferably Transformr to save you the work of manually parsing the event data.


You can use the file_get_contents function or the curl extension for that.


First fetch the content of the whole page from that website as a string, then use regular expression to extract the substring inside table tags.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号