Eléphant du PHP |
89 Messages
09 août 2010, 14:00
Salut Stealth
Je suis entrin d'apprendre Xpath pour trouver facilement les donnée que je veut avoir.
J'aimerai récupérer une URL toujours sur steam, sans passer par leur api.
Voici l'url
<a href="http://steamcommunity.com/profiles/76561197984780389">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Steam Community :: Home :: SLK/4pa</title>
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link href="http://steamcommunity.com/public/css/skin_1/global.css?v=185539828" rel="stylesheet" type="text/css" />
<link href="http://steamcommunity.com/public/css/skin_1/profile_home.css?v=3570665286" rel="stylesheet" type="text/css" />
<link href="http://steamcommunity.com/public/css/skin_1/header.css?v=2949346048" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://steamcommunity.com/public/javascript/prototype-1.6.0.2.js?v=1535683511&l=english"></script>
<script type="text/javascript" src="http://steamcommunity.com/public/javascript/scriptaculous/scriptaculous.js?v=2361208777&l=english&load=effects,controls,slider"></script>
<script type="text/javascript" src="http://steamcommunity.com/public/javascript/global.js?v=3661003391&l=english"></script>
<script type="text/javascript" src="http://steamcommunity.com/public/javascript/profile_home_functions.js?v=3022667372&l=english"></script>
<script type="text/javascript" src="http://steamcommunity.com/public/javascript/modal.js?v=1837892742&l=english"></script>
<script type="text/javascript" language="javascript">
var processURL = 'http://steamcommunity.com/profiles/76561197984780389/home_process';
var cgroupinvites = 0;
var cplayerinvites = 0;
var ckicks = 0;
</script>
</head>
<body>
<center>
<!-- header bar, contains info browsing user if logged in -->
<div id="global_header">
<div class="content">
<div class="logo">
<span id="logo_holder">
<a href="http://store.steampowered.com/">
<img src="http://steamcommunity.com/public/images/header/globalheader_logo.png" width="176" height="44" border="0" />
</a>
</span>
<!--[if lt IE 7]>
<style type="text/css">
#logo_holder img { filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0); }
#logo_holder { display: inline-block; width: 176px; height: 44px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='http://steamcommunity.com/public/images/header/globalheader_logo.png'); }
</style>
<![endif]-->
</div>
<a class="menuitem" href="http://store.steampowered.com/">
STORE </a>
<a class="menuitem active" href="https://steamcommunity.com/">
<div class="activebg"> </div>
Community </a>
<a class="menuitem" href="http://store.steampowered.com/news/">
NEWS </a>
<a class="menuitem" href="http://store.steampowered.com/forums/">
FORUMS </a>
<a class="menuitem" href="http://store.steampowered.com/about/">
ABOUT </a>
<a class="menuitem" href="http://support.steampowered.com/">
SUPPORT </a>
<a class="menuitem" href="http://store.steampowered.com/stats/">
STATS </a>
<div id="global_actions">
<div class="user_avatar friendBlockIcon">
<div class="iconHolder_offline"><div class="avatarIcon"><a href="http://steamcommunity.com/profiles/76561197984780389"><img src="http://media.steampowered.com/steamcommunity/public/images/avatars/63/63a635a02683daa23639f303180b426f090c6c96.jpg" /></a></div></div>
</div>
<div id="global_action_menu">
<a href="http://steamcommunity.com/?action=doLogout">LogOut</a>
|
<span class="pulldown" id="language_pulldown" onclick="ShowMenu( this, 'language_dropdown', 'right' );">language</span>
<div class="popup_block" id="language_dropdown" style="display: none;">
<div class="shadow_ul"></div><div class="shadow_top"></div><div class="shadow_ur"></div><div class="shadow_left"></div><div class="shadow_right"></div><div class="shadow_bl"></div><div class="shadow_bottom"></div><div class="shadow_br"></div><div class="iepoupfix"><img class="iepoupfix_img" src="http://steamcommunity.com/public/images/trans.gif"></div>
<div class="popup_body popup_menu shadow_content">
<a class="popup_menu_item tight" href="?l=danish">
<h5>Dansk (Danish)</h5>
</a>
<a class="popup_menu_item tight" href="?l=czech">
<h5>ce�tina (Czech)</h5>
</a>
<a class="popup_menu_item tight" href="?l=dutch">
<h5>Nederlands (Dutch)</h5>
</a>
<a class="popup_menu_item tight" href="?l=finnish">
<h5>Suomi (Finnish)</h5>
</a>
<a class="popup_menu_item tight" href="?l=french">
<h5>Fran�ais (French)</h5>
</a>
<a class="popup_menu_item tight" href="?l=german">
<h5>Deutsch (German)</h5>
</a>
<a class="popup_menu_item tight" href="?l=hungarian">
<h5>magyar (Hungarian)</h5>
</a>
<a class="popup_menu_item tight" href="?l=italian">
<h5>Italiano (Italian)</h5>
</a>
<a class="popup_menu_item tight" href="?l=japanese">
<h5>??? (Japanese)</h5>
</a>
<a class="popup_menu_item tight" href="?l=korean">
<h5>??? (Korean)</h5>
</a>
<a class="popup_menu_item tight" href="?l=norwegian">
<h5>Norsk (Norwegian)</h5>
</a>
<a class="popup_menu_item tight" href="?l=polish">
<h5>Polski (Polish)</h5>
</a>
<a class="popup_menu_item tight" href="?l=portuguese">
<h5>Portugu�s (Portuguese)</h5>
</a>
<a class="popup_menu_item tight" href="?l=romanian">
<h5>Rom�na (Romanian)</h5>
</a>
<a class="popup_menu_item tight" href="?l=russian">
<h5>??????? (Russian)</h5>
</a>
<a class="popup_menu_item tight" href="?l=schinese">
<h5>???? (Simplified Chinese)</h5>
</a>
<a class="popup_menu_item tight" href="?l=spanish">
<h5>Espa�ol (Spanish)</h5>
</a>
<a class="popup_menu_item tight" href="?l=swedish">
<h5>Svenska (Swedish)</h5>
</a>
<a class="popup_menu_item tight" href="?l=tchinese">
<h5>???? (Traditional Chinese)</h5>
</a>
<a class="popup_menu_item tight" href="?l=thai">
<h5>??? (Thai)</h5>
</a>
</div>
</div>
</div>
</div>
</div>
</div>
Merci
EDIT: est ce que cette expression marcherai?
$doc = new DOMDocument();
$doc->loadHTMLFile(http://.......);
$xpath = new DOMXPath($doc);
$sid = $xpath->query('//div[@class="avatarIcon"/a[@href=$url]')->item(0)->value;
Modifié en dernier par
ferv21 le 09 août 2010, 16:05, modifié 1 fois.