试图实现PHP爬虫?(Trying to implement a PHP crawler?)
我正在尝试在我的网站中实现PHP爬虫。 我的主要动机是从其他网站获得产品的价格。 为此,我试图使用dom解析器,但我的脚本无法正常工作。 我解析一个类为prc的div的代码是: -
<?php include('simplehtmldom/simple_html_dom.php'); $html = file_get_html('http://www.ebay.in'); $html->find('div', 1)->class = 'prc'; echo $html; ?>
I am trying ti implement the PHP crawler in my website. My main motive is to get the price of the product from other websites. For that i am trying to use dom parser but my script is not working. my code for parsing a div whose class is prc is:-
<?php include('simplehtmldom/simple_html_dom.php'); $html = file_get_html('http://www.ebay.in'); $html->find('div', 1)->class = 'prc'; echo $html; ?>
原文:https://stackoverflow.com/questions/18306717
更新时间:2023-09-16 09:09
最满意答案
试试这个 - :由于您已经使用双引号,所以包装代码是单引号。
add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = '[su_spoiler title="Download The File" style="fancy" icon="chevron-circle"]Here[/su_spoiler]'; return $content; }
Try this -: wrap your code is a single quote as you are already using double quotes.
add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = '[su_spoiler title="Download The File" style="fancy" icon="chevron-circle"]Here[/su_spoiler]'; return $content; }
相关问答
更多-
您必须将“car”类别slug或ID作为wp_set_object_terms的第二个参数传递。 尝试 wp_set_object_terms($post_ID, "car", ‘portfolio_category’); 如果“car”不是您的术语slug,请首先检索术语ID。 $term = get_term_by( 'name', 'car', 'portfolio_category' ); $term_id = (int) $term->term_id; wp_set_object_terms($ ...
-
在wordpress中使用内置函数来包含文件: - 提供header.php它会带来它。 ID), array( 2600,1000 ), false, '' );?>$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); 你可以使用函数get_post_thumbnail_id()来获得相同的图像 $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );我在测试了一些其他选项之后找到了答案: 'categories'=>array("telesync", "1080p"), $ content变量如下所示: $content = array( 'title'=>$title, 'description'=>$body, 'mt_allow_comments'=>0, // 1 to allow comments 'mt_allow_pings'=>0, // 1 to allow trackbacks 'pos ...
缺少WordPress“Post Article”默认菜单,而不是HTML(Missing WordPress “Post Article” default menu, not the HTML one)[2022-07-25]
案例1:转到用户>您的个人资料并取消选中“写入时禁用可视编辑器”。 案例2:如果问题繁荣,则尝试选择另一个默认模板。 如果问题得到解决,请检查模板的functions.php文件,因为它导致了问题。 案例3:您的某个插件可能存在问题。 将它们全部停用,然后重试。 希望问题能够得到解决。 Case 1: Go to Users > Your Profile and uncheck "Disable the visual editor when writing". Case 2: If the problem ...get_the_category()返回一个数组,但在您的回调函数中,您将该数组用作字符串。 这就是为什么得到这个错误。 这是你的代码的简化和固定版本,我没有测试它,但它应该工作。 function add_default_podcast_title( $data, $postarr ) { if ( 'podcasts' === $data['post_type'] && empty( $data['post_title'] ) ) { $ashow = 'prefix'; ...有了这个args,你可以显示帖子。 $posts_per_page = get_option('posts_per_page'); $args = array('paged'=>$paged, 'posts_per_page'=>$posts_per_page, 'post_type'=> 'post', 'post_status'=>'publish' ); query_posts($args); 然后使用Wp分页 ...试试这个 - :由于您已经使用双引号,所以包装代码是单引号。 add_filter( 'default_content', 'my_editor_content' ); function my_editor_content( $content ) { $content = '[su_spoiler title="Download The File" style="fancy" icon="chevron-circle"]Here[/su_spoiler]'; return $content; ...wordpress添加帖子验证(wordpress add post validation)[2022-12-02]
这不是一个bug, WordPress故意这样做(为了保存修订版AFAIK)。 无论如何,这可能会有效但可能比这更好(粘贴在你的functions.php文件中) add_action( 'admin_notices', 'custom_error_notice' ); function custom_error_notice(){ global $current_screen, $post; if ( $current_screen->parent_base == 'edit' ){ ...我不确定在WordPress中是否有直观的方法(您可能需要在https://wordpress.stackexchange.com/上查看)。 但是,我会解释我之前是如何做到这一点的。 创建一个新的页面模板,比如php.php ,用你想要的“默认”页面来做。 通常,我包含一个仅从我的自定义帖子类型中提取的循环。 然后,在名为“ ...相关文章
更多- Becoming a data scientist
- 关于PHP爬虫和Android定位的初步设想
- Solr PHP support
- php匹配问题
- [ solr扩展 ] Different ways to implement autosuggest using SOLR
- Drupal Forums instead of phpBB or vBulletin: A casestudy
- php solr 扩展
- PHP中的替代语法
- [转]So You Want To Be A Producer
- my php & mysql FAQ
最新问答
更多- 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
- 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
- OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
- 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
- codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
- 在计算机拍照在哪里进入
- 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
- No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
- 单页应用程序:页面重新加载(Single Page Application: page reload)
- 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
- System.StackOverflow错误(System.StackOverflow error)
- KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
- 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
- android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
- TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
- 企业安全培训的各项内容
- 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
- C#类名中允许哪些字符?(What characters are allowed in C# class name?)
- NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
- 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
- 将多个行和可变行移动到列(moving multiple and variable rows to columns)
- 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
- 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
- Angular $资源不会改变方法(Angular $resource doesn't change method)
- 在Angular 5中不是一个函数(is not a function in Angular 5)
- 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
- 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
- 常见的python rpc和cli接口(Common python rpc and cli interface)
- Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
- 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)