Skip to content


Subversion checkout URL

You can clone with
Download ZIP
PHP proxy that converts webpages to json objects, filtered by jquery-like selectors.
Branch: master
Failed to load latest commit information.
LICENSE minor Minor / typo
index.php minor
phpQuery-onefile.php initial commit
post.html clean up


PHP proxy that converts webpages to json objects, filtered by jquery-like selectors (Built on top of PHPQuery).

Takes parameters from GET or POST.

Think of it as a 'shotgun api'. Because many sites still don't provide apis.




This is a debug flag.

If set, it will var_dump the results for improved readibility. If not, a json-encoded object is returned.


The url to go scrape and make JSON from.

For complex urls already using GET (ie. some search engines) you can POST url instead.




Comma separated list of selectors, in a jQuery fashion

PHP can't parse # from a url as it's never sent to the server ('url fragments').

Because of this, use % instead of #.

You can, but are not forced to, use two underscores (__) for a space (so it doesn't look like %20)

Get attributes by using a '|'

By default it will return 'text()'

a        ---> will return all text of the A tags
a|html   ---> will return all html contents of the A tags
a|href   ---> will return all href attribute of the A tags
img|src  ---> will return all src attribute of the img tags


span.hey ---> will return all spans with class hey
span%hey ---> will return all spans with id hey (I know)
div%pad table:first a ---> div#pad table:first a

Complex Example using __ instead of space:

Within #results, will return the 4th column, 2nd span, b's html


Real world examples

Latest currencies $ from Reuters

index.php?url=,%currPairs__td:first-child__a|href,%currPairs__td:nth- child(2)

  "sel":"#currPairs td:first-child a,#currPairs td:first-child a|href,#currPairs td:nth-child(2)",


Hacker News

There is an unofficial api but anyway, this works too.


  "sel":".title a:first-child,.title a:first-child|href",
      "Octopress - A blogging framework for hackers",
      "NoSQL is What?",
      "Radio Shack to start stocking Arduino, Other Goodies",


Australia Bureau of Meteorology (bom)

The bom is known for not having decent a api.

Take a look at its home page ... We're going to grab the Forecast as presented for the major cities.


%pad__table:first__a, (grab the #pad then the first table's A tags text)
%pad__table:first__.max, (the maximas, has class .max)
%pad__table:first__td:last-child (grab the last TD of the first table)

  "sel":"#pad table:first a,#pad table:first .max,#pad table:first td:last-child",
      "Possible shower clearing."
      "Shower or two."


(\u00b0 is the unicode for the DEGREE sign)

Feel free to improve

Not much of this is perfect, it comes from flaws in its quirky design, also the PHP could be improved.

If you have some PHP experience in your legs and want to improve the code and/or add features, I'd gladly take changes (fork away!).

Something went wrong with that request. Please try again.