#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    107
    Rep Power
    1

    How To Check Whether An Html Element Or Plain Text Exists On A Page Or Not


    Pros,


    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:
    https://twitter.com/TangoForce123

    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.


    Thanks
  2. #2
  3. Forgotten Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Mar 2007
    Location
    Washington, USA
    Posts
    16,019
    Rep Power
    9616
    Don't do it that way. Use their API to do a search for people who tweeted at you.
  4. #3
  5. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Caro, Michigan
    Posts
    14,667
    Rep Power
    4495
    You'd want to use the above method if you're talking specifically about Twitter, but the basic string and regular expression functions could be used otherwise, to look for matching text.

    PHP: strpos - Manual

    PHP: preg_match - Manual
    -- Cigars, whiskey and wild, wild women. --
  6. #4
  7. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2016
    Location
    Lakewood, WA
    Posts
    98
    Rep Power
    17
    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.
    I'm sorry, I don't understand. name=username is not an HTML element.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2017
    Posts
    107
    Rep Power
    1
    Thank you Requinix and Sepodati.

IMN logo majestic logo threadwatch logo seochat tools logo