phpquery

How to chain in phpquery (almost everything can be a chain)

旧街凉风 提交于 2019-12-12 00:22:56
问题 Good day everyone, I'm very new with phpquery and this is my first post here at stackoverflow for a reason that i cant find the correct for syntax for the phpquery chaining. I know someone knows what i been looking for. I only want to remove the a certain div inside a div. <div id = "content"> <p>The text that i want to display</p> <div class="node-links">Stuff i want to remove</div> </content> This few lines of codes works perfect pq('div.node-links')->remove(); $text = pq('div#content');

Parse SOAP response using PHP?

你。 提交于 2019-12-11 18:13:19
问题 I parsed HTML content as a SOAP response but I can't retrieve it in client. This is the PHP code I used to parse the SOAP response: $obj = simplexml_load_string(read_file('../soap.xml')); var_dump($obj->children('http://schemas.xmlsoap.org/soap/envelope/')); Here is the SOAP response: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

How does PhpQuery work? Trying to get the value of <title> tag

不羁岁月 提交于 2019-12-07 09:30:04
问题 I'm new to phpQuery. I need to achieve the simple task of getting the content of the HTML TITLE tag of a webpage. In this case I'm trying to get the title content of "Yahoo!" that should be "Yahoo!". I'm doing this with phpQuery, but it is now working // Testing phpQuery $result = phpQuery::newDocumentFile($scraps['Scrap_yahoo']->getPage('http://www.yahoo.com','','off')) ->find('title'); echo $result->text(); Can someone give me a clue on how to achieve this? Best Regards, 回答1: I think the

因 php 默认的 url encode 编码标准引发的一个问题

孤街醉人 提交于 2019-12-06 02:17:07
先看常用的校验请求合法性的一个方式 function createToken($params) { $secretKey = 'secretKey'; ksort($params); $query = http_build_query($params); $token = md5($query . $secretKey); return $token; } function createQuery($params) { $params['token'] = createToken($params); $query = http_build_query($params); return $query; } function checkQuery($params) { $token = $params['token']; unset($params['token']); return $token == createToken($params); } $params = [ 'k1' => 'v1', 'k2' => 'v2', 'time' => time() ]; $query = createQuery($params); echo $query, PHP_EOL; parse_str($query, $result); var_dump(checkQuery($result))

How does PhpQuery work? Trying to get the value of <title> tag

这一生的挚爱 提交于 2019-12-05 16:14:40
I'm new to phpQuery . I need to achieve the simple task of getting the content of the HTML TITLE tag of a webpage. In this case I'm trying to get the title content of "Yahoo!" that should be "Yahoo!". I'm doing this with phpQuery, but it is now working // Testing phpQuery $result = phpQuery::newDocumentFile($scraps['Scrap_yahoo']->getPage('http://www.yahoo.com','','off')) ->find('title'); echo $result->text(); Can someone give me a clue on how to achieve this? Best Regards, mario I think the problem might be your phpQuery invocation with ::newDocumentFile() . This function needs a filename

Android pass and receive parameter from PHP

旧时模样 提交于 2019-12-04 05:09:19
问题 how to pass parameter from one activity to php side and received by another activity? in php side, i will do query, so my query depends on passed parameter from one activity and another activity will show the result of that query. thanks for your helps. 回答1: 1> how to pass parameter android app to php site. 1> create one json parser class JSONParser.java public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public

Scraping Library for PHP - phpQuery?

前提是你 提交于 2019-12-03 06:02:42
问题 I'm looking for a PHP library that allows me to scrap webpages and takes care about all the cookies and prefilling the forms with the default values, that's what annoys me the most. I'm tired of having to match every single input element with xpath and I would love if something better existed. I've come across phpQuery but the manual isn't much clear and I can't find out how to make POST requests. Can someone help me? Thanks. @Jonathan Fingland: In the example provided by the manual for

phpQuery使用DOMDocument::loadHTML方法产生报错的处理方式

半世苍凉 提交于 2019-12-02 20:22:44
发现问题 在做爬虫的时候,用了QueryList,在运行的过程中查看日志,出现很多关于phpQuery单文件的error报错,问题是出在html非标准化格式 [ error ] [2]DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1262[/home/querying/PhpstormProjects/xianlang10.com/EngineSeo/vendor/jaeger/phpquery-single/phpQuery.php:328] [ error ] [2]DOMDocument::loadHTML(): htmlParseEntityRef: expecting ';' in Entity, line: 1262[/home/querying/PhpstormProjects/xianlang10.com/EngineSeo/vendor/jaeger/phpquery-single/phpQuery.php:328] 解决问题 在查看 php手册 关于 DOMDocument 类 loadHTML 方法的使用的时候,发现 libxml_use_internal_errors 可以对此类错误,强制以 libxml_get_errors() 进行获取

使用phpQuery轻松采集网页内容

给你一囗甜甜゛ 提交于 2019-12-02 20:22:34
phpQuery是一个基于PHP的服务端开源项目,它可以让PHP开发人员轻松处理DOM文档内容,比如获取某新闻网站的头条信息。更有意思的是,它采用了jQuery的思想,你可以像使用jQuery一样处理页面内容,获取你想要的页面信息。 DEOM演示 采集头条 先看一实例,现在我要采集新浪网国内新闻的头条,代码如下: include 'phpQuery/phpQuery.php'; phpQuery::newDocumentFile('http://news.sina.com.cn/china'); echo pq(".blkTop h1:eq(0)")->html(); 简单的三行代码,就可以获取头条内容。首先在程序中包含phpQuery.php核心程序,然后调用读取目标网页,最后输出对应标签下的内容。 pq()是一个功能强大的方法,跟jQuery的$()如出一辙,jQuery的选择器基本上都能使用在phpQuery上,只要把“.”变成“->”。如上例中,pq(".blkTop h1:eq(0)")抓取了页面class属性为blkTop的DIV元素,并找到该DIV内部的第一个h1标签,然后用html()方法获取h1标签里的内容(带html标签),也就是我们要获取的头条信息,如果使用text()方法,则只获取头条的文本内容。当然要使用好phpQuery,关键是要找对文档中对应内容的节点

Android pass and receive parameter from PHP

自闭症网瘾萝莉.ら 提交于 2019-12-02 05:35:08
how to pass parameter from one activity to php side and received by another activity? in php side, i will do query, so my query depends on passed parameter from one activity and another activity will show the result of that query. thanks for your helps. 1> how to pass parameter android app to php site. 1> create one json parser class JSONParser.java public class JSONParser { static InputStream is = null; static JSONObject jObj = null; static String json = ""; // constructor public JSONParser() { } public JSONObject getJSONFromUrl(String url, List<NameValuePair> params) { // Making HTTP request