Jump to content

seblondres

Members
  • Posts

    50
  • Joined

  • Last visited

seblondres's Achievements

Newbie

Newbie (1/7)

0

Reputation

  1. Thanks for taking the time to answer my question. I have tried $result->Offer->Merchant->Logo->Url but unfortunately it still doesn't picking up the merchant logo url while I don't have any problems to get to the other child nodes.
  2. Hi, I have this code below to retrieve the products from the XML further down, I can get to any children but the Merchant logo URL. If someone could please let me know how to reach the Merchant logo URL. foreach ($productsResult->Products->Product as $result) { echo "<a href=".$result->Offer->Url." target='_blank'><img class='productImg' src=".$result->Offer->Images[0]->Image->Url."/></a>"; echo "<p><b class='price'>£".$result->Offer->Price->Price."</b></p><br>"; echo "<p><img src=".$result->Offer->Merchant[0]->Name->Logo->Url."/></p>"; // This is where I need help echo "<p class='title'>".$result->Offer->Title.".</p><a class='goToStore w3-btn w3-blue' href=".$result->Offer->Url." target='_blank'><b>Visit Store</b></a>"; <Products> <Product> <Offer> <Title></Title> <Description> </Description> <Images> <Image available="true"> <Url></Url> <Height></Height> <Width></Width> </Image> <Merchant> <Name></Name> <Logo> <Url>The URL I need</Url> <Width></Width> <Height></Height> </Logo> </Merchant> Thanks,
  3. Ok I found a solution to my post: $keywords = explode("\n", file_get_contents('keywords.txt')); $search = $keywords[ array_rand($keywords) ]; Instead I passing the random keywords as a query keyword='.$search.' in my API url: e.g. $productsResult = simplexml_load_file('http://site.com?publisherId=xxx&placementId=&categoryId=&keyword='.$search.'&apiKey=xxxx'); Thanks,
  4. Hi, I have this script below which select random keywords from a file: <?php $search = explode("\n", file_get_contents('keywords.txt')); $search[ array_rand($search) ]; ?> Now I want to randomly pass those keywords in an URL so I can $_Get them e.g. http://example.com/index.php?keyword={A random keyword from my text file} If someone could point me to the right direction. Many Thanks,
  5. seblondres

    Indeed API

    Hi, I'm trying to detect whether <totalresults> = 0 from the Indeed API. Here is the code I'm using: <?php $search ='oihhb'; $xml = simplexml_load_file('http://api.indeed.com/ads/apisearch?publisher=xxxxxx&q='.$search.'&l=&sort=&radius=&st=&jt=&start='.$start.'&limit=1&fromage=&filter=&latlong=1&co=fr&chnl=&userip=1.2.3.4&useragent=Mozilla/%2F4.0%28Firefox%29&v=2'); foreach($xml->results->result as $result) if ($xml->totalresults == 0) { echo 'empty'; } else { echo $xml->totalresults; } ?> As you can see from the code above, I'm searching for $search ='oihhb'; which purposely doesn't return any results - see <query> below: <response version="2"> <query>oihhb</query> <location/> <dupefilter>true</dupefilter> <highlight>false</highlight> <totalresults>0</totalresults> <start>0</start> <end>0</end> <pageNumber>0</pageNumber> <results></results> </response> So I want to do, it's to echo 'empty' if <totalresults> = 0 but I can't get it work i.e. I can't print 'empty'. However I have to say that I can print the total number of results: echo $xml->totalresults; So must be something wrong with if ($xml->totalresults == 0). If someone could point me to the right direction. Many Thanks,
  6. Got it, thanks! <?phpinclude_once 'simple_html_dom.php';$search_term = array( "lyon", "cannes", "paris", "marseille" );for($i=0;$i<count($search_term);$i++){ $city = $search_term[$i]; $url = "http://www.pole-emploi.fr/annuaire/?TypeServices=0&VilleLieu={$city}&annusearch=1&Chercher=Chercher";$html = file_get_html($url);$ret = $html->find('div[class=Annuaire-int]');foreach($ret as $story) echo $story;}?>
  7. Thanks for your reply. I'm not sure what you mean exactly, would you be able to send me an example or to point me to a link/doc? Many Thanks,
  8. I've tried the following but I can only display the information for Paris: <?phpinclude_once 'simple_html_dom.php';$search_term = array( "lyon", "cannes", "paris" ); foreach ($search_term as $search_term) { $url = "http://www.pole-emploi.fr/annuaire/?TypeServices=0&VilleLieu={$search_term}&annusearch=1&Chercher=Chercher";}$html = file_get_html($url);$ret = $html->find('div[class=Annuaire-int]');foreach($ret as $story) echo $story;?>
  9. I just want to search one term at the time, something with foreach perhaps
  10. Hi, I have the script below which works fine when searching 1 term (city). Now what I like to do, it's to search through multiple terms, so how can I pass one term after the other into the $url so I can get the result for each term on the same page. Ideally I'd like to be able to read a txt file with all the terms (cities). <?phpinclude_once 'simple_html_dom.php';$search_term = "paris";$url = "http://www.domain.net/annuaire/?TypeServices=0&VilleLieu={$search_term}&annusearch=1&Chercher=Chercher";$html = file_get_html($url);$ret = $html->find('div[class=Annuaire-int]');foreach($ret as $story) echo $story;?> Thanks,
  11. ok good to know, I'll put more information next time. thanks a lot!
  12. ok I solved my problem, the below does what I want: <?php$city = $_GET['city'];$url = ('http://www.test2.com/directory/'. $city );?> Thanks,
  13. Thanks for your answers: The variable $url would be used to scrape this page for example: http://www.test2.com/directory/london-greenwich Here is how it should works: 1. I'm on the index page and I have a link http:/test1.com/directory.php?city=london-greenwich 2. When I click on the link above I'm redirected to directory.php which contain the php file above with the variable $city = $_GET['city']; 3. With this variable $city = $_GET['city']; I should be able to get "london-greenwich" 4. Then I want to add that piece of url "london-greenwich" to $url = "http://www.test2.com/directory/" 5. So I can build the following url $url = "http://www.test2.com/directory/london-greenwich" Thanks,
  14. Hi, I'm trying to build a url in the php file below from a url in the browser. URL in the browser: http:/test1.com/directory.php?city=london then I like to get the city and add it at the end of the url in the php file below so it looks like that: http://www.test2.com/directory/london so far I go this but I can only access http://www.test2.com/directory/ <?php$city = $_GET['city'];$fields = array('city' => $city);$url = "http://www.test2.com/directory/". http_build_query($fields, '');?> Thanks for your help,
×
×
  • Create New...