Last active
          October 6, 2020 05:51 
        
      - 
      
- 
        Save remoharsono/72d60a93846de69ce4587ceb0f63dffd to your computer and use it in GitHub Desktop. 
    answering question on twitter
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <?php | |
| // https://twitter.com/the_paTiku/status/1276075890812878848 | |
| require 'vendor/autoload.php'; | |
| use GuzzleHttp\Client; | |
| use GuzzleHttp\Exception\RequestException; | |
| use GuzzleHttp\Psr7\Request; | |
| use DiDom\Document; | |
| use DiDom\Query; | |
| $client = new \GuzzleHttp\Client(); | |
| $base = 'https://resellers.tp-partner.pl'; | |
| $url = $base . '/?action=sklepy&cmd=getCity&pr=zachodniopomorskie'; | |
| $response = $client->request('GET', $url); | |
| $html = (string) $response->getBody(); | |
| $document = new Document($html); | |
| $links = $document->find('.miasta > li > a::attr(href)'); | |
| foreach($links as $link) { | |
| $url = $base . $link; | |
| $response = $client->request('GET', $url); | |
| $html = (string) $response->getBody(); | |
| $document = new Document($html); | |
| $emails = $document->find('.email > a::attr(href)'); | |
| if (!empty($emails)) { | |
| echo str_replace("mailto:", "", $emails[0]) . "\n"; | |
| } | |
| } | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment