duandongji2231 2016-08-05 08:42
浏览 86
已采纳

使用php从html页面中的特定行提取数据

this was my original question I was stuck and tried to solve my problem by trying something and got stuck again

I need to extract name of candidate and his id from a pdf ,so after using pdfparser I extracted the text and downloaded the html page using php

<?php
$filename = 'filename.html';
header('Content-disposition: attachment; filename=' . $filename);
header('Content-type: text/html');
// ... the rest of your file
?>
<?php

// Include Composer autoloader if not already done.
include 'C:\Users\amite\Downloads\pdfparser-master (1)\pdfparser-master\vendor\autoload.php';

// Parse pdf file and build necessary objects.
$parser = new  \Smalot\PdfParser\Parser();
$pdf    = $parser->parseFile('C:\Users\amite\Desktop\Data\001.ApplicationForm-CSE-2015-1-omokop (3).pdf');

$text = $pdf->getText();
echo $text;


?>

I did this cause the info I need that was on line 12 and 13 of the view source page and this was was with all the pdf's I need ,so after downloading the html file I used the code below to see the source page of html file

<?php
show_source("filename.html");
?> 

now when I run the above program I got the source page of html file which I downloaded, now I need to extract data from line 12 and 13 , the output of program looks like this :-

<html>
 text
 text
text
text 
text 
text   

there are no tags except html tag and info I need is on line 12,13, if you need any clarification please ask me I will tell you. how should I extract text from line 12,13, if there is another way tell me pls. I am stuck again, if the question is vague I will clarify it or improve it, please help me.

  • 写回答

2条回答 默认 最新

  • duangou1551 2016-08-05 08:55
    关注

    Store the file source into an array with $source = file('filename.html'); and extract line 12 and 13 via array index 11 and 12 like this echo $source[11]; //line 12

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入
  • ¥40 使用MATLAB解答线性代数问题
  • ¥15 COCOS的问题COCOS的问题