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

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











In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.
