doucuo9126 2012-02-28 20:08
浏览 6
已采纳

将href的内容插入URL参数

Here's my problem, say, for example, I have a link on my page, it will look something like:

<a href="12/345/67.php">Stuff here</a> - on page 1

Simple stuff.

The thing is, when that link is clicked, I need it to write the contents of of the href="" part to a url parameter for page two. So:

page2.php?url=12/345/67.php

The other problem here is that I'm using the simple html dom web scraper to make this page (page 1) so I get my links like this:

$html = file_get_html('http://www.somesite.com/somepage.html');

foreach($html->find('a') as $e)
    $e->style= 'color:#000; padding-left:5px; text-align:left;';

Any ideas? Thanks in advance!

  • 写回答

1条回答 默认 最新

  • duandou8457 2012-02-28 20:21
    关注

    Try something like this:

    $href = urlencode($e->href);
    $e->href = "page2.php?url=$href";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 ARIMA模型时间序列预测用pathon解决
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对
  • ¥15 误删注册表文件致win10无法开启
  • ¥15 请问在阿里云服务器中怎么利用数据库制作网站
  • ¥60 ESP32怎么烧录自启动程序,怎么查看客户esp32板子上程序及烧录地址
  • ¥50 html2canvas超出滚动条不显示
  • ¥15 java业务性能问题求解(sql,业务设计相关)