I'm trying to extract HTML from a website in the form of a string, and then I want to extract particular elements from the string using the substr function:
here is some sample code that I have thus far:
So, the variable $content seems to be an HTML object or something that is NOT a string. How can I convert $content to a string, so that I can use the substr function?
I have tried other methods including simpler code:
however, I am not able to process $content as a string.
I have even tried putting the contents into a text file, but I am not able to extract a string from a text file either?
any help is appreciated!!!
here is some sample code that I have thus far:
Code:
use HTTP::Request::Common; use LWP::UserAgent; use LWP::Simple; $ua = LWP::UserAgent->new; $request = HTTP::Request->new(GET => 'http://www.cnn.com'); $response = $ua->request($request); $content = $response->content(); my $result2 = substr $content, index($content, 'Headlines');
I have tried other methods including simpler code:
Code:
my $content = get('http://securities.stanford.edu//1014/TCHC00');
I have even tried putting the contents into a text file, but I am not able to extract a string from a text file either?
any help is appreciated!!!
Comment