php新手求助: 如何获取超链接的title值?
php 获取链接文字
如题。如一个超链接:
超链接标题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的显示和隐藏就好了,这样蜘蛛也能抓得到
嗯,谢谢。

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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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

Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

The enumeration function in PHP8.1 enhances the clarity and type safety of the code by defining named constants. 1) Enumerations can be integers, strings or objects, improving code readability and type safety. 2) Enumeration is based on class and supports object-oriented features such as traversal and reflection. 3) Enumeration can be used for comparison and assignment to ensure type safety. 4) Enumeration supports adding methods to implement complex logic. 5) Strict type checking and error handling can avoid common errors. 6) Enumeration reduces magic value and improves maintainability, but pay attention to performance optimization.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.
