Imagine you want to only provide your download link to those who tweet about you. Now, how would you code it ?
Let's make it simple for you to understand.
Let's say you want to write a php script that checks if a certain html element (eg. name=username) or plain text exists or not.
If it exists then to give you an alert "TRUE"; Else alert: FALSE.

In this example, you want the script to check this page:

And you want it to check if the following text (exact match) exists or not:
"I'd like to put forward an Idea"

How would you code it ? Can we see 2-3 examples ?
I'd be grateful if you can show another example for a fuzzy match. Eg:

  • like to put forward *

    This is an interesting topic. Base the boolean around what exists or not on a page.
    Curious to see what the code would look like and php is capable of doing it in how many lines of code.


8 Months
Discussion Span
Last Post by diafol

In the specific case of Twitter, there is an API that allows to search through the public tweets of a specific account:

You can check the libraries used to connect this service here and see how it is done:

If you want to check the contents of a static page and here I mean the contents generated on server side and loaded in plain HTML, you can use a library to analyze the DOM, like:

DOM libraries require valid documents, if these are malformed then the extraction can fail.

If, instead, the contents are loaded through Javascript, you need a browser engine and some javascript, see as example:

A part these, there are many other available solutions, like regular expressions or scripting with command line tools as awk or sed:

Also, if the goal is to extract data, don't limit your choices to PHP, there are excellent solutions written in other languages, see for example Scrapy:

Curious to see what the code would look like and php is capable of doing it in how many lines of code.

Hehe, I think you can try to extract the tweet through a DOM library (DOM Crawler should be easy to use), check the HTML source of the link you provided, load the page and see what you can get from there.



I don't understand all that DOM stuffs. ALthought, heard of it before.
Anyway, thankls for the Scrapy link.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.