Bonjour,
Je voudrais modifier ce type d'url :
Par
Code : Sélectionner tout - Visualiser dans une fenêtre à part http://www.ddd.com/video/fzezzz?syndication=54545
Le but étant de modifier de récupérer ce type d'url la chaine présente entre "video/" et "?", donc ici cela serait "fzezzz"
Code : Sélectionner tout - Visualiser dans une fenêtre à part http://www.bbb.fr/ddd/fzezzz/
J'ai le code source ci-dessous, mais cela ne fonctionne pas, savez-vous pourquoi svp ??
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 <!doctype html> <html lang="fr"> <head> <meta charset="utf-8"> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script type="text/javascript"> function replace_url(){ var els = document.querySelectorAll("a[href^='http://www.ddd.com']"); //console.log(els); if(els){ for (var i = 0, l = els.length; i < l; i++) { els_url=els[i].getAttribute("href"); var id_video=els_url.replace(/^http:\/\/www.ddd.com\/video\/([a-z0-9]{4-6})\?syndication=54545$/,'http://www.bbb.fr/ddd/$1/'); console.log("2:"+id_video); } } } jQuery(document).ready(function() { replace_url(); }); </script> </head> <body> <a itemprop="url" href="http://www.ddd.com/video/fzezzz?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/ggezgre?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/fezfz?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/zefze?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/vhygt?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/berty?syndication=54545" target="_blank" >fzezfzefe</a> <a itemprop="url" href="http://www.ddd.com/video/aopml?syndication=54545" target="_blank" >fzezfzefe</a> </body> </html>
Merci beaucoup pour votre aide
Partager