![]() |
how to post text from url in wordpress? I have WordPress e commerce site with responsive comparison theme , Now I have setup crawler which scrapes the price from various pages . This crawler gives me an api (url) which i want to post instead of numeric values. Now how do I program it to get the data from url and if the data from url is not available then to use another variable which would contain a fallback price. I want to use this api because the crawler runs every 15 minutes and could help me in getting live data. I would be importing these urls through csv import tool. I modified class_core.php file to this: Price Display ================================================== ======================== */ function curl_download($Url){ // is cURL installed yet? if (!function_exists('curl_init')){ die('Sorry cURL is not installed!'); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $Url); curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm"); curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0"); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_TIMEOUT, 10); $output = curl_exec($ch); curl_close($ch); return $output; } $url_for_value = "https://www.xyz.com/dddddd/ddddd"; // remember to add http colon and two slashes in front of url... // stackoverflow tools won't let me do that here... $val = curl_download($url_for_value); function PRICE($val){ if(!is_numeric($val) && defined('WLT_JOBS') ){ // if not numeric, e.g. $100 , strip off non-numeric characters. preg_match_all('/([\d]+)/', $val, $match); // Do we have a valid number now? if (!is_numeric($match[0]){ // perform other tests on return info from the CURL function? return $val; } $val = $match[0]; } but this code doesnt work it gives me 500 internal error In short can anyone tell how to post text from url in price function |
| All times are GMT -6. The time now is 07:39 PM. |