PHP Page Viewer


Here is a fully working PHP page viewer, set the variables $pages[] = "ANY URL HERE"; to suit your needs, and change the variable $max = 10; to however many views you want for each $page.


LastMitch commented: Thanks for sharing! +9
About the Author

$max = 10; // Set this to how many views you want per page
$time_to_wait = 3; // Time between views

$pages[] = ""; // Copy and paste this line and change the link inside the quotes to just the plain video link nothing else.
$pages[] = "";

foreach($pages as $page)
	$view_counter[$page] = 0;
	while($view_counter[$page] < $max)
		$view_counter[$page] ++;
		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $page);
        curl_setopt($curl, CURLOPT_FAILONERROR, true);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
		curl_setopt($curl, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 5.1; rv:15.0) Gecko/20121004 Firefox/15.2 PaleMoon/15.2"); // So you don't annoy google
		$return = curl_exec($curl);
			echo "Success ($page): ".$view_counter[$page]."! <br />";
			echo "Failure ($page): ".$view_counter[$page]."! <br />";
		sleep($time_to_wait); // Allow a break to stop blacklisting

Member Avatar

@Caelan Stewart

I finally figure out how this works. It's taking too long.

Is there another way to speed this up?

Even though you set it here:

$time_to_wait = 3; // Time between views

It's nice. I like it. It would be nicer if you adding comments how each function works.

I attach a image how the results looks like:


Echo89 9 Web Developer

Set the variable $time_to_wait to 1, or even 0.5, to make it go faster.

Member Avatar

Question - what's the purpose of this code?

Echo89 9 Web Developer

There is no purpose really, apart to get page views on specific threads on a websited.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.