Ho inserito la tua proposta nel mio script in questo modo (giusto per testarne il funzionamento):
Codice PHP:
<?php
//salvo la pagina
$url = "paginatest.html";
$page = @file_get_contents($url) or die('Could not access file: $url');
$pattern = '#[url="([^"]]*>([^<]*)[/url]\s*
\s*<SPAN[^>]*>(.*?)</SPAN>#si';
preg_match_all("$pattern", $page, $matches, PREG_SET_ORDER);
foreach($matches as $match) {
$Result = $match[0];
echo "$Result";
}
?>
il risultato che ottengo a schermo è il seguente:
Personal Information
View and update emergency contact information; Review name or social security number change information.
Student and Financial Aid
Register for classes; Display your class schedule; View your holds; Display grades/transcripts; Review financial aid requirements/awards; Charges/Payments/Refunds - Please view your account through the online Account Center. The link is located after you login to Braveweb but before you enter Banner Self Service.
Employee
Time sheets, time off, benefits, leave or job data, paystubs, W4 data.
Il codice html del risultato ottenuto è il seguente:
Codice PHP:
[url="/tsbss/pls/TEST/twbkwbis.P_GenMenu?name=bmenu.P_GenMnu"]Personal Information[/url]
<SPAN class=menulinkdesctext >View and update emergency contact information; Review name or social security number change information.</SPAN>[url="/tsbss/pls/TEST/twbkwbis.P_GenMenu?name=bmenu.P_StuMainMnu"]Student and Financial Aid[/url]
<SPAN class=menulinkdesctext >Register for classes; Display your class schedule; View your holds; Display grades/transcripts; Review financial aid requirements/awards; [b]Charges/Payments/Refunds - Please view your account through the online Account Center. The link is located after you login to Braveweb but before you enter Banner Self Service.[/b]</SPAN>[url="/tsbss/pls/TEST/twbkwbis.P_GenMenu?name=pmenu.P_MainMnu"]Employee[/url]
<SPAN class=menulinkdesctext >Time sheets, time off, benefits, leave or job data, paystubs, W4 data.</SPAN>
Le informazioni sono tutte agglomerate insieme e sono allo stesso punto di partenza. Mi trascino dietro anche molti tag html che non voglio ottenere. Come posso ottenere i 3 array distinti, con i singoli elementi separati, come descritto nell'altr post? Sbaglio qualcosa io?
Ho bisogno di avere i singoli elementi per inserirli al mio richiamo in un altra struttura html formattata in un altro modo. Quindi mi servono gli elementi ASSOLUTI, url del link, nome del link, descrizione, tutto senza tag.
Ad esempio i link:
Attualmente ottengo
Codice PHP:
<A HREF="/tsbss/pls/TEST/twbkwbis.P_GenMenu?name=bmenu.P_GenMnu" class=submenulinktext2 onMouseover="window.status='Personal Information'; return true" onMouseout="window.status=''; return true" onFocus="window.status='Personal Information'; return true" onBlur="window.status=''; return true" >
ma vorrei ottenere semplicemente il percorso dell'url niente di piu cioè:
/tsbss/pls/TEST/twbkwbis.P_GenMenu?name=bmenu.P_GenMnu
Ho pensato ad una seconda azione di ripulitura sulla stringa ottenuta, tramite uno str_replace ma non mi sembra una soluzione molto pulita. Ci sarebbe un modo più diretto tramite un'espressione regolare per andare direttamente a prelevare ciò che mi serve?