Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a webpage with a small table, for example:

<table>
    <tbody>
        <tr>
            <td class="123">
                <div class="box-title title collapsed-box">
                    <a class="title" href="URL" target="_top" title="TITLE" data-original-click-url="URL">
                        <span>TEXT</span>
                    </a>
                </div>
            </td>
        </tr>
    </tbody>
</table>

in this table there is link, which is changing every several minutes (doesn't matter time).

How can I fully copy URL without cutting anything?

P.S. I don't know PHP so it will be great if you'll explain to me with examples

share|improve this question
1  
Are you able to load the source code of that website into a string variable in PHP? –  x-ray 19 hours ago
1  
SO isn't a free coding service, please try yourself and come back if you run into problems –  Epodax 19 hours ago
    
If you don't know PHP then why are you using PHP? –  Martin 18 hours ago

3 Answers 3

You cat parse URL with regexp

|click-url\=\"(.*)\">|

$string = '<table>
<tbody>
<tr>
<td class="123">
<div class="box-title title collapsed-box">
<a class="title" href="URL" target="_top" title="TITLE" data-original-click-url="URL"><span>TEXT</span></a>
</div>
</td>
</tr>
</tbody>
</table>';

preg_match_all('|click\-url\=\"(.*)\">|', $string, $matches);

var_dump($matches);

Example: http://ideone.com/KJg8y2

Your result in $matches[1][0]

share|improve this answer
    
<?php $url="URL of another website"; $ch = curl_init($url); curl_setopt($ch, CURLOPT_USERAGENT, 'IE20'); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1'); $text = curl_exec($ch); curl_close($ch); $table = "/<table>(.*)<\/table>/siU"; preg_match($table, $text, $data); echo $data[1]; ?> I'm trying to do this with this code but URL is cutted for example another webpages name is google.com/sport/abg.php when I parse by this code at my website I get result as mywebsite.com/abg.php google.com and directory /sport/ is gone –  SPoX 18 hours ago
<?php echo $_SERVER['REQUEST_URI']; ?> 

the above is to echo the url.. try this...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.