XPATH

The XPATH(XML Path Language) is a query language from the W3C, it is used to select nodes in an XML file.

Full Path

/html/body/div

In this example I start with “/” that say we start on root and then i navigate from element to element.

 

Anywhere

//a

In this example I use the “//” to search in the full document to find all a nodes.(you could use the “//” behind a “/” like “/html/body/div//a” to find all elements in html body div.)

 

Attributes

//div[@class="secondary"]

you could use the “@” to find all elements wit the attribute class that is the string “secondarary”.

 

As example you could select all hrefs where the Attributes contains a string:

//a[contains(@href,"scheinast")]

Or select all hrefs where the text from the URL contains a string:

//a[contains(text(),"Scheinast")]

 

Array

//a[1]

If you select all Elements you get an Array, in the example above I select the firs element from my result Array.You should avoid this, better is to navigate over the class or ID because if the Page changes a bit the XPATH don’t work any more.

 

That are some basics, if you need something special take a look into the Network or on my page.As example Web crawling in PHP or Perl.

PHP image upload

This is my image upload solution:

<form action="upload.php" method="post" enctype="multipart/form-data">
    Select image to upload:
    <input type="file" name="fileToUpload" id="fileToUpload">
    <input type="submit" value="Upload Image" name="submit">
    <br>
    By clicking the Upload button you accept that you are the owner of the file.
</form>

 <?php
$target_dir = "./i/";
$target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]);
$ext = pathinfo(basename($_FILES["fileToUpload"]["name"]), PATHINFO_EXTENSION);
$uploadOk = 1;
$FILENAME = hash_file("md5",$_FILES["fileToUpload"]["tmp_name"]).".".$ext;
$imageFileType = pathinfo($target_file,PATHINFO_EXTENSION);
// Check if image file is a actual image or fake image
if(isset($_POST["submit"])) {
    $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]);
    if($check !== false) {
        $uploadOk = 1;
    } else {
        echo "<h5>File is not an image.</h5>";
        $uploadOk = 0;
    }
	// Check if file already exists
	if (file_exists("./i/".$FILENAME)) {
	    echo "<h5>Sorry, file already exists.</h5>";
	    create_output($FILENAME);
	    $uploadOk = 0;
	}
	// Check file size
	if ($_FILES["fileToUpload"]["size"] > 5000000) {
	    echo "<h5>Sorry, your file is too large.</h5>";
	    $uploadOk = 0;
	}
	// Allow certain file formats
	if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg"
	&& $imageFileType != "gif" && $imageFileType != "svg" ) {
	    echo "<h5>Sorry, only JPG, JPEG, SVG PNG & GIF files are allowed.</h5>";
	    $uploadOk = 0;
	}
	// Check if $uploadOk is set to 0 by an error
	if ($uploadOk == 1){
	    if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], "./i/".$FILENAME)) {
		echo "<h5>The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded.</h5>";
		create_output($FILENAME);
	    } else {
		echo "<h5>Sorry, there was an error uploading your file.</h5>";
	    }
	}
}else{
	echo "<br><br><br><br>Recent uploaded images:<br>";
	$files = scandir($target_dir);
	$count = 0;
	foreach($files as $result) {
		if( $result != "." && $result !=".."){
    			echo "\n<a href='http://scheinast.eu/i/$result' target='_blank'><img src='http://scheinast.eu/i/$result' style='width:304px;height:228px'></a>";
    		}
    		if($count > 10){break;}++$count;
	}

}


function create_output($FILE){
echo "<a href='http://scheinast.eu/i/$FILE'>http://scheinast.eu/i/$FILE</a>";
echo "<a href='http://scheinast.eu/i/$FILE'><img src='http://scheinast.eu/i/$FILE'></img></a>";
}

?> 
</body>
</html>

The name its stored is always an md5 hash of the file to avoid duplicate files.

PHP crawl example

This is a little example how to crawl a web page with PHP, in this example I crawl my own page with XPATH to get all titles.

<?php
# turn erros of
libxml_use_internal_errors(true);
# creat DomDocument Object
$DOM = new DomDocument;
# load the THML
$DOM->loadHTMLFile("/");
# creat DomXPath Object
$XPATH = new DomXPath($DOM);
# get all titles with XPATH
$mynodes = $XPATH->query("//article//header//h1");
# print result
foreach ($mynodes as $i => $mynodes) {
    echo "[$i] => '", $mynodes->nodeValue, "'n";
}
?>

This is our result, this are the matches from the XPATH:

[0] => 'create multiple file in shell with touch'
[1] => 'Format current Date in Perl and Bash'
[2] => 'Perl Print Benchmark'
[3] => 'Perl simple Data Dumper for references'
[4] => 'Arduino C Program LED Blink'
[5] => 'Perl Constant Benchmark'
[6] => 'Benchmark Debug perl'
[7] => 'Programmier-Einleitung in C/C++'
[8] => 'perl debug output'
[9] => 'crontab via script'

To see this in Perl click: Perl crawl example.

P-Project

P-Project is a Porn Video Crawl Engine IN PHP AND PERL. Watch here new collected videos from different sites. You can register to our site to like and dislike videos and use the playlist feature.
We are currently searching for partner for Backlink change,Video share or traffic sharing.If you want to add a site,give feedback or have a question to our page, please support to our Administrator.

Start screen:

Bildschirmfoto vom 2014-11-25 20:26:11

Random Videos:

Bildschirmfoto vom 2014-11-17 21:23:14

Video Editor: Bildschirmfoto vom 2014-11-25 20:40:07

Amazone Store:Bildschirmfoto vom 2014-11-25 20:43:21

Web cams:Bildschirmfoto vom 2014-11-25 20:44:51

Mobile Site:index

Things from this project:

Generate Preview Jpeg/gif from Video

Sitemap Generator

WATCHDOG

main.pl

 P-Project CSS