php
  • regex
  • http
  • https
  • 2017-03-25 2 views 1 likes 
    1

    Ich habe diese PHP-Code:Regex Suche in Seite http und https

    $cinemagiaprepare=file_get_contents("http://www.bing.com/search?q=$numele+$anul+site:https://www.cinemagia.ro/filme/&format=rss&count=1"); 
    $cinepatern='#<\/title><link>(https:\/\/www.cinemagia.ro.+?)<\/link><description>#'; 
    if (preg_match($cinepatern, $cinemagiaprepare, $matchc)) 
    $numeletv1=($matchc[1]); 
    

    Das ist Code-Suche in: http://www.bing.com/search?q=Walk%20of%20Fame%202017%20site:https://www.cinemagia.ro/filme/&format=rss&count=1

    für diesen Link http://www.cinemagia.ro/filme/world-premiere-2009x00-1650809

    nur Mein Code https suchen. Ich möchte nach https und http suchen.

    ich versuchen, diese Regex:

    $cinepatern='#<\/title><link>(https.*:\/\/www.cinemagia.ro.+?)<\/link> 
    

    Demo: https://regex101.com/r/oNeMMb/1 diese Regex den gesamten Code auszuwählen.

    +0

    Der '/' muss nicht entkommen werden, wenn es als verwendet wird ein Trennzeichen URLs können auch protokollunabhängig sein. Am besten nutzt man einen Parser und zieht das 'link' Element. – chris85

    Antwort

    1

    Für die optionale s in https, wäre es dies sein

    '#</title><link>(https?://www\.cinemagia\.ro.+?)</link><description>#'

    0

    Mit SimpleXML:

    $sxe = simplexml_load_file('http://www.bing.com/search?q=$numele+$anul+site:https://www.cinemagia.ro/filme/&format=rss&count=1'); 
    
    echo $sxe->xpath('//link[starts-with(., "http://www.cinemagia.ro") or starts-with(., "https://www.cinemagia.ro")]')[0]; 
    
    Verwandte Themen