<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Youtube Scraper</title>
	<atom:link href="http://blackhatseo-blog.com/youtube-scraper/feed" rel="self" type="application/rss+xml" />
	<link>http://blackhatseo-blog.com/youtube-scraper</link>
	<description>spam 2.0</description>
	<lastBuildDate>Wed, 17 Feb 2010 04:16:51 +0100</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: sonmen</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-67533</link>
		<dc:creator>sonmen</dc:creator>
		<pubDate>Fri, 27 Nov 2009 03:16:20 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-67533</guid>
		<description>if you guys are looking for good tools to get back links, i found some good ones at this website here

http://www.webthangs.com</description>
		<content:encoded><![CDATA[<p>if you guys are looking for good tools to get back links, i found some good ones at this website here</p>
<p><a href="http://www.webthangs.com" rel="nofollow">http://www.webthangs.com</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scraper code in php</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-36947</link>
		<dc:creator>Scraper code in php</dc:creator>
		<pubDate>Thu, 12 Feb 2009 02:25:34 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-36947</guid>
		<description>[quote comment=&quot;&quot;] have not done many PHP projects but I always think that PHP is really good for web programming even though I mostly program in Java and .NET.

I am not a good PHP programmer, but to write a simple web page scraper in PHP is very straightforward.

First, I defined my HTTP get/post function

function http_post_content($url,$data) {
	$data = http_build_query($data);
	$aContext = array(
		&#039;http&#039; =&gt; array(
		&#039;proxy&#039; =&gt; &#039;proxyserver:8080&#039;,
		&#039;request_fulluri&#039; =&gt; True,
		&#039;method&#039;=&gt;&#039;POST&#039;,
		&#039;header&#039;=&gt;
                &quot;Content-type:  application/x-www-form-urlencoded\r\n&quot;
		.&quot;Content-Length: &quot; . strlen($data) . &quot;\r\n&quot;,
		&#039;content&#039; =&gt; $data
				),
	    	);
	$cxContext = stream_context_create($aContext);
	$content = file_get_contents($url, FILE_TEXT, $cxContext);
	return $content;

	/*
	$fp = @fopen($url, &#039;rb&#039;, false, $cxContext);
	if (!$fp) {
	    throw new Exception(&quot;Problem with $url, $php_errormsg&quot;);
	}
	$content = @stream_get_contents($fp);
	if ($content === false) {
		throw new Exception(&quot;Problem reading data
                from $url, $php_errormsg&quot;);
	}
	*/
}
In the http array I can define the proxy server settings, method which can be post or get, and the content.

I use file_get_contents to retrieve the web page instead of cURL, which is more powerful.

To test it,


$url=&quot;http://biz.thestar.com.my/marketwatch/main.asp&quot;;
$data=array(&#039;bns&#039;=&gt;&#039;2&#039;,
        	&#039;clp&#039;=&gt;&#039;1&#039;,
        	&#039;klseViewDate&#039;=&gt;&#039;1/30/2008&#039;
        	);
$content = http_post_content($url,$data);
$htmlDoc = new DomDocument();
@$htmlDoc-&gt;loadHTML($content);
$xPath = new DOMXPath($htmlDoc);
$counters = $xPath-&gt;evaluate(&#039;//table[@id=&quot;Table2&quot;]
/tr/td[2]/center/table/tr/td/span
[@class=&quot;text&quot;]/table/tr/td/a&#039;);
for ($i = 0; $i length; $i++){
	print($counters-&gt;item($i)-&gt;nodeValue.’‘);
}
I pass in the URL and the post data, then I use XQuery to retrieve the information that I want. 

Note the HTML may not be well-formed, so I suppress the warning by prefixing a @ in front.

One of the catch here is the correct XQuery/XPath to be used. You can always find out using Solvent, which is a very good FireFox plug-in for web page scraping.
quote]</description>
		<content:encoded><![CDATA[<blockquote comment=""><p>
 have not done many PHP projects but I always think that PHP is really good for web programming even though I mostly program in Java and .NET.</p>
<p>I am not a good PHP programmer, but to write a simple web page scraper in PHP is very straightforward.</p>
<p>First, I defined my HTTP get/post function</p>
<p>function http_post_content($url,$data) {<br />
	$data = http_build_query($data);<br />
	$aContext = array(<br />
		&#8216;http&#8217; =&gt; array(<br />
		&#8216;proxy&#8217; =&gt; &#8216;proxyserver:8080&#8242;,<br />
		&#8216;request_fulluri&#8217; =&gt; True,<br />
		&#8216;method&#8217;=&gt;&#8217;POST&#8217;,<br />
		&#8216;header&#8217;=&gt;<br />
                &#8220;Content-type:  application/x-www-form-urlencoded\r\n&#8221;<br />
		.&#8221;Content-Length: &#8221; . strlen($data) . &#8220;\r\n&#8221;,<br />
		&#8216;content&#8217; =&gt; $data<br />
				),<br />
	    	);<br />
	$cxContext = stream_context_create($aContext);<br />
	$content = file_get_contents($url, FILE_TEXT, $cxContext);<br />
	return $content;</p>
<p>	/*<br />
	$fp = @fopen($url, &#8216;rb&#8217;, false, $cxContext);<br />
	if (!$fp) {<br />
	    throw new Exception(&#8221;Problem with $url, $php_errormsg&#8221;);<br />
	}<br />
	$content = @stream_get_contents($fp);<br />
	if ($content === false) {<br />
		throw new Exception(&#8221;Problem reading data<br />
                from $url, $php_errormsg&#8221;);<br />
	}<br />
	*/<br />
}<br />
In the http array I can define the proxy server settings, method which can be post or get, and the content.</p>
<p>I use file_get_contents to retrieve the web page instead of cURL, which is more powerful.</p>
<p>To test it,</p>
<p>$url=&#8221;http://biz.thestar.com.my/marketwatch/main.asp&#8221;;<br />
$data=array(&#8217;bns&#8217;=&gt;&#8217;2&#8242;,<br />
        	&#8216;clp&#8217;=&gt;&#8217;1&#8242;,<br />
        	&#8216;klseViewDate&#8217;=&gt;&#8217;1/30/2008&#8242;<br />
        	);<br />
$content = http_post_content($url,$data);<br />
$htmlDoc = new DomDocument();<br />
@$htmlDoc-&gt;loadHTML($content);<br />
$xPath = new DOMXPath($htmlDoc);<br />
$counters = $xPath-&gt;evaluate(&#8217;//table[@id="Table2"]<br />
/tr/td[2]/center/table/tr/td/span<br />
[@class="text"]/table/tr/td/a&#8217;);<br />
for ($i = 0; $i length; $i++){<br />
	print($counters-&gt;item($i)-&gt;nodeValue.’‘);<br />
}<br />
I pass in the URL and the post data, then I use XQuery to retrieve the information that I want. </p>
<p>Note the HTML may not be well-formed, so I suppress the warning by prefixing a @ in front.</p>
<p>One of the catch here is the correct XQuery/XPath to be used. You can always find out using Solvent, which is a very good FireFox plug-in for web page scraping.<br />
quote]</p>
</blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-33631</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Sun, 25 Jan 2009 01:14:53 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-33631</guid>
		<description>This code doesn&#039;t work.Just gives me a blank page :(</description>
		<content:encoded><![CDATA[<p>This code doesn&#8217;t work.Just gives me a blank page <img src='http://blackhatseo-blog.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt Longley</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-24242</link>
		<dc:creator>Matt Longley</dc:creator>
		<pubDate>Mon, 13 Oct 2008 20:16:53 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-24242</guid>
		<description>Thanks for the script, that will come in handy on a new project that I am working on. =)</description>
		<content:encoded><![CDATA[<p>Thanks for the script, that will come in handy on a new project that I am working on. =)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Wayne</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-23982</link>
		<dc:creator>Wayne</dc:creator>
		<pubDate>Wed, 08 Oct 2008 22:54:12 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-23982</guid>
		<description>Thanks for this. I&#039;ve been wondering how to get something like this working for a while.

Wayne</description>
		<content:encoded><![CDATA[<p>Thanks for this. I&#8217;ve been wondering how to get something like this working for a while.</p>
<p>Wayne</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Zaiaku</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-990</link>
		<dc:creator>Zaiaku</dc:creator>
		<pubDate>Tue, 03 Jul 2007 23:56:12 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-990</guid>
		<description>No it wont post automatically but will give your site or page dynamic content.</description>
		<content:encoded><![CDATA[<p>No it wont post automatically but will give your site or page dynamic content.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arpit</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-930</link>
		<dc:creator>Arpit</dc:creator>
		<pubDate>Thu, 31 May 2007 15:52:33 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-930</guid>
		<description>Will this make my blog automated? Or should I have to add any cronjob or something to control the frequency of updating my blog?</description>
		<content:encoded><![CDATA[<p>Will this make my blog automated? Or should I have to add any cronjob or something to control the frequency of updating my blog?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: busin3ss</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-925</link>
		<dc:creator>busin3ss</dc:creator>
		<pubDate>Thu, 31 May 2007 15:27:42 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-925</guid>
		<description>[quote comment=&quot;838&quot;]I don&#039;t have any idea of how to use this script. Can you please give us some detailed instruction for doing it? I have messaged you on Digital point forum about this. Please guide me.[/quote]

It&#039;s actually really easy, just copy the code and save it on a file (youtube.php for example). Then wherever you want to insert a Youtube video related to a keyword, just add this:

require_once(&#039;youtube.php&#039;); // assuming your file is called youtube.php

And then just wherever you want to see the video add this:

youtube(&#039;bmw&#039;); // this will include a youtube video about BWM</description>
		<content:encoded><![CDATA[<blockquote><p>
I don&#8217;t have any idea of how to use this script. Can you please give us some detailed instruction for doing it? I have messaged you on Digital point forum about this. Please guide me.</p>
</blockquote>
<p>It&#8217;s actually really easy, just copy the code and save it on a file (youtube.php for example). Then wherever you want to insert a Youtube video related to a keyword, just add this:</p>
<p>require_once(&#8217;youtube.php&#8217;); // assuming your file is called youtube.php</p>
<p>And then just wherever you want to see the video add this:</p>
<p>youtube(&#8217;bmw&#8217;); // this will include a youtube video about BWM</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arpit</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-924</link>
		<dc:creator>Arpit</dc:creator>
		<pubDate>Thu, 31 May 2007 15:22:04 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-924</guid>
		<description>I don&#039;t have any idea of how to use this script. Can you please give us some detailed instruction for doing it? I have messaged you on Digital point forum about this. Please guide me.</description>
		<content:encoded><![CDATA[<p>I don&#8217;t have any idea of how to use this script. Can you please give us some detailed instruction for doing it? I have messaged you on Digital point forum about this. Please guide me.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ShinZaiaku</title>
		<link>http://blackhatseo-blog.com/youtube-scraper/comment-page-1#comment-945</link>
		<dc:creator>ShinZaiaku</dc:creator>
		<pubDate>Tue, 29 May 2007 00:20:15 +0000</pubDate>
		<guid isPermaLink="false">http://blackhatseo-blog.com/?p=12#comment-945</guid>
		<description>Warning: preg_match() expects parameter 2 to be string, resource given in /home/public_html/004/youtube.php on line 5

I&#039;m getting this error.</description>
		<content:encoded><![CDATA[<p>Warning: preg_match() expects parameter 2 to be string, resource given in /home/public_html/004/youtube.php on line 5</p>
<p>I&#8217;m getting this error.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
