php新手: 如何获取超链接的title值?
如题。
如一个超链接:
超链接标题9
用 $_GET['title']可以获取" HypeLinkTitle",那如何获取" 超链接标题8"和" 超链接标题9"?
希望大虾能就这个超链接给点提示,谢谢!
回复讨论(解决方案)
通过js传输
超链接标题9
var _h = $('hplink').html();
然后呢? 初学php,望能详细点哈。
通过js传输
超链接标题9
var _h = $('hplink').html();
然后呢? 初学php,望能详细点哈。
$('#hplink').html();
$('#hplink').attr('title');
通过js传输
超链接标题9
var _h = $('hplink').html();
然后呢? 初学php,望能详细点哈。
<!DOCTYPE html><html> <head></head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function (){ $('#xxxxx').click(function (){ var t = $(this).attr('title'); var h = $(this).html(); var r = $(this).attr('rel'); //字符串连接, var u = r + '&testTitle='+ t + '&testHtml=' + h; alert(u); }); }) </script> <body> <a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a> </body></html>
通过js传输
超链接标题9
var _h = $('hplink').html();
然后呢? 初学php,望能详细点哈。
<!DOCTYPE html><html> <head></head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function (){ $('#xxxxx').click(function (){ var t = $(this).attr('title'); var h = $(this).html(); var r = $(this).attr('rel'); //字符串连接, var u = r + '&testTitle='+ t + '&testHtml=' + h; alert(u); }); }) </script> <body> <a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a> </body></html>
谢谢。也感谢 fire53。
获取这个我会啊,现在的问题是,我要如何把这取得的值传回到php?
想实现的作用是,点击这个链接,php后台就根据这个链接超本文从数据库读取相关的文章。
其他都弄好了,现在就差如何将获取的超文本传给php了。
链接的形式是
超链接标题8
通过js传输
超链接标题9
var _h = $('hplink').html();
然后呢? 初学php,望能详细点哈。
<!DOCTYPE html><html> <head></head> <script type="text/javascript" src="jquery-1.7.1.min.js"></script> <script type="text/javascript"> $(function (){ $('#xxxxx').click(function (){ var t = $(this).attr('title'); var h = $(this).html(); var r = $(this).attr('rel'); //字符串连接, var u = r + '&testTitle='+ t + '&testHtml=' + h; alert(u); }); }) </script> <body> <a href="javascript:;" rel="http://www.example.com/?title=HypeLinkTitle" title="testTitle" id="xxxxx">testHtml</a> </body></html>
这种 onclick + rel 的形式,百度蜘蛛可以正常获取链接并爬过去么?
传回到php ?
$('#hplink').attr('title');
谢谢,如何将这值传给php呢?希望能详细点,谢谢!
传回到php ?
版主的阿大,是的。
想实现的作用是,点击这个链接,php后台就根据这个链接的超本文从数据库读取相关的文章。蜘蛛要能爬的到。
js获取到了,然后可以通过get或者post传回啊。。。
直接都放到问号后面不就行啦
http://www.example.com/?title=HypeLinkTitle__超链接标题8__超链接标题9__超链接标题100
get后再explode分割开来
$title_list = explode("__", $_GET['title']);
echo $title_list[0];
echo $title_list[1];
echo $title_list[100];
传回到php ?
版主的阿大,是的。
想实现的作用是,点击这个链接,php后台就根据这个链接的超本文从数据库读取相关的文章。蜘蛛要能爬的到。
你这是要动态取文章?
用ajax把参数传后台处理,success方法里把返回的文章内容显示在页面上。这样蜘蛛是抓不到的啊。
js获取到了,然后可以通过get或者post传回啊。。。
应该就是这个办法,能就这个链接给点代码提示么?
你这是要动态取文章?
用ajax把参数传后台处理,success方法里把返回的文章内容显示在页面上。这样蜘蛛是抓不到的啊。
蜘蛛抓不到就没用咯。谢谢
直接都放到问号后面不就行啦
http://www.example.com/?title=HypeLinkTitle__超链接标题8__超链接标题9__超链接标题100
get后再explode分割开来
$title_list = explode("__", $_GET['title']);
echo $title_list[0];
echo $title_list[1];
echo $title_list[100];
传回到php ?
版主的阿大,是的。
想实现的作用是,点击这个链接,php后台就根据这个链接的超本文从数据库读取相关的文章。蜘蛛要能爬的到。
这种方法是可以的,但问题是现在链接的形式就已经定死了。谢谢
PHP没法活的HTML页面上的元素值,只能通过$_GET,$_POST等获得form元素里的值。
这个只能通过第三方传输。
你可以先把这个文档放在文本框中,然后通过$(".标记类")获取,也可以通过js方法判断隐藏和显示不就行了么,为什么非要搞什么超链接》》
你可以先把这个文档放在文本框中,然后通过$(".标记类")获取,也可以通过js方法判断隐藏和显示不就行了么,为什么非要搞什么超链接》》
是一个web程序,不搞链接蜘蛛不好整呐,谢谢!
PHP没法活的HTML页面上的元素值,只能通过$_GET,$_POST等获得form元素里的值。
这个只能通过第三方传输。
嗯,谢谢。如果两个都是泼诶取泼呢?
PHP没法活的HTML页面上的元素值,只能通过$_GET,$_POST等获得form元素里的值。
这个只能通过第三方传输。
嗯,谢谢。如果两个都是泼诶取泼呢?
泼诶取泼? PHP?
我想了下,我回答错了
html的话,可以用curl抓取回来用正则匹配
php的话用可以用fopen, 去除多余的字符(空格换行之类的),再正则匹配。
不要要实现你这个想法,还是按楼上的
一下子全部放到dom里,用js切换dom的显示和隐藏就好了,这样蜘蛛也能抓得到
不要要实现你这个想法,还是按楼上的
一下子全部放到dom里,用js切换dom的显示和隐藏就好了,这样蜘蛛也能抓得到
嗯,谢谢。
/ https://www.baidu.com/

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
