开发者

PHP/Javascript - Posting parameters to page, then parsing new html?

开发者 https://www.devze.com 2023-02-01 04:35 出处:网络
FINAL EDIT: I got the DOMxpath query to work using the following code: $divs = $xpath->evaluate(\"/html/body//div/table[@id=\'resulttable\']\");

FINAL EDIT:

I got the DOMxpath query to work using the following code:

$divs = $xpath->evaluate("/html/body//div/table[@id='resulttable']");

I don't understand, though, why this code doesn't work the same way:

开发者_运维技巧$divs = $xpath->query("//table[@id='resulttable']");

ANY IDEAS?


ok. The classes aren't actually listed and searched dynamically via Javascript, it's a pretty standard static form... you're going to want to use cURL to get the generated pages by submitting your required POST parameters. your POST parameters are:

0       TERM    select                  
1       DIVS    select                  
2       CAMPUS  select                  
3       SUBJ    select          4       
4       ATTR    select                  
5       CREDIT  select                  
6           submit  Search


You can POST and fetch results using curl in PHP. Try this tutorial http://www.electrictoolbox.com/php-curl-form-post/

Also, you can figure out what parameters to post by inspecting AJAX request in Firebug


Adding another answer since this is a totally different question now.

I don't know why it's not working, everything is ok according to manual. But may I suggest using phpQuery instead? I tried that when I had a similar task. This way you can rewrite you expression as

/** @var $pq phpQuery */
$divs = $pq->find('table#resulttable');

and use other familiar jQuery methods.

0

精彩评论

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