Giter Site home page Giter Site logo

phpscraper's Introduction

phpScraper

A class that helps you extract information from a text (it can be an HTML page).

Methods:

error()

Return last error code

  • 0 = no error
  • 1 = can't read file

filereset()

Move pointer to begining

fileread($file,$sleep=false,$usecurl=false)

Read the text form an URL

  • $file = URL
  • $sleep = wait $sleep seconds between requests
  • $usecurl = if true it uses the cURL library instead of file_get_contents()

filefeed($text)

Feed the text into the class

  • $text = text to feed

seekto($text)

Search for the text and move the pointer after it

  • $text = text to search

getposition()

Get current pointer position

setposition($pos)

Set pointer position. If the new value is greater than the text's length, nothing happens

  • $pos = new pointer position

getfile()

Get current text

search($text1,$text2,$text3,$dir='forward')

Search for $text1, then search for $text2, and return the text between $text2 and $text3

  • $text1 - search for this text from the current pointer position and move the pointer after it
  • $text2 - search for this text next and move the pointer after it (this parameter can be '' and nothing will happen)
  • $text3 - copy the text between the current pointer position and the beginning of $text3
  • $dir - direction for the search for $text1

istext($text)

Search for $text and return true if it's found

strip_diacritics($x)

Strip some diacritic characters from $x. Returns result.

Example:

<?php

  $a=new Parser();
  $a->fileread('http://somesite.com/somefile.html');
  $a->seekto('<div class="top">');
  do {
    $text=$a->search('<li>','','</li>');
    if ($text!==false) {
        echo "$text<br/>";
    }
  } while ($text!==false);

?>

phpscraper's People

Contributors

pandronic avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.