dtvx3420 2014-04-06 13:19
浏览 76

TCPDF我无法从另一个页面获取html,比如index.php?something = something

I am struggling to create a pdf file with tcpdf from a dynamically generated page.

My problem is that I've got a logging session and when accessing the file it gets only the credentials if you're not logged in.

So my bit for collecting the html is:

$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL,'http://www.domain.com/subdir/index.php?something=ref');
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$html = curl_exec($curl_handle);
curl_close($curl_handle);

So what I've got after running it, is 'HTTP Error 401: - Unauthorised'.

I hope my explanation makes sense.

Any help will be much appreciated!

  • 写回答

1条回答 默认 最新

  • doukanzhuo4297 2014-11-10 13:22
    关注

    I had the same issue while working with PDF using TCPDF where in curl CURLOPT_USERAGENT was TCPDF like below.

    curl_setopt($curl_handle, CURLOPT_USERAGENT, 'TCPDF');
    

    I just commented this line and try to generate pdf and it worked.

    I know this is not a proper way but it worked for me.

    评论

报告相同问题?

悬赏问题

  • ¥15 用hfss做微带贴片阵列天线的时候分析设置有问题
  • ¥50 我撰写的python爬虫爬不了 要爬的网址有反爬机制
  • ¥15 Centos / PETSc / PETGEM
  • ¥15 centos7.9 IPv6端口telnet和端口监控问题
  • ¥120 计算机网络的新校区组网设计
  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 海浪数据 南海地区海况数据,波浪数据
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等