Hi,
Right now i am working on alternative ways to open links in websites. Just check this plugin for firefox - https://addons.mozilla.org/en-US/firefox/addon/879/ .. Try that plugin. You can see numbers attached to each link on a site.
What i need is a similiar functionality, but without the plugin. Instead i am using a proxy server script using 'php curl'. Then i will put a virtual keyboard with 'number pad(means only numbers from 0 to 9 and not the whole virtual keyboard') only and pressing the numbers by eyetracker or a softswitch ( these two are devices used by physically challanged people) will open the links in the websites.
In short, i need to use the plugin property without plugin and need to remove the entering of numbers from keyboard to a 'virtual keyboard'.
I had succeed in extrating links from a given webiste. The code is given below. Just run and check it ur self.
<?php
$url='http://www.espn.com';
$var = fread_url($url); // function calling to get the page from curl
$linktext = preg_replace("/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/", "'/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>123"."([^<]+|.*?)?<\/a>/", $var);
print $var; //printing the page
preg_match_all ("/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/",$var, $matches);
$matches = $matches[1];
$list = array();
foreach($matches as $var)
{
$var='<a href="'.$var.'">'.$var.'</a>';
print($var."<br>"); // printing the links
}
function fread_url($url,$ref="")
{
if(function_exists("curl_init")){
$ch = curl_init();
$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; ".
"Windows NT 5.0)";
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERAGENT, $user_agent);
curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION , 1 );
curl_setopt( $ch, CURLOPT_URL, $url );
curl_setopt( $ch, CURLOPT_REFERER, $ref );
curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
$html = curl_exec($ch);
//print $html;//printing the web page.
curl_close($ch);
}
else{
$hfile = fopen($url,"r");
if($hfile){
while(!feof($hfile)){
$html.=fgets($hfile,1024);
}
}
}
return $html;
}
?>
Here i cann extract the links. But i can't modify the links in the espn.com. Just like the firefox addon, i need to add nmbers to each link name. If u try the addon, u will get what i need.