如何从Linkedin API获取公司徽标? [英] How to get company logo from Linkedin API?

查看:137
本文介绍了如何从Linkedin API获取公司徽标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Linkedin& amp;上做了一个模拟的公司简介.已上传了两张图片(请参阅问题底部的屏幕截图),而我正尝试获取第二张图片(大).

I made a mock company profile on Linkedin & have uploaded two images (see screenshot at bottom of question) and I'm trying to get the second image (large).

我可以同时使用logo-urlsquare-logo-url.我得到的信息如下:

I can get the first image using both the logo-url and square-logo-url from the list of Company Profile fields in the Linkedin docs. The info I get back looks like this:

{
    'logoUrl': 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAagAAAAJDMwYzRhOGVmLWU3MzUtNGUyNi05YTgzLWU3MzVhOGViNGYyZA.png',
    'squareLogoUrl': 'https://media.licdn.com/mpr/mpr/AAEAAQAAAAAAAAS6AAAAJDI4ODQ4NTgxLTQzZGQtNDEzZi1iZjIwLWNiNDgxZTk2NmE5ZA.png',
    'description': "Bla bla",
    etc. etc.
}

链接 logoUrl

The links logoUrl and squareLogoUrl are linked to a square version of the first image.

有人知道我如何从Linkedin API中获得更大的图像吗?欢迎所有答案!

Does anybody know how I can get the larger image from the Linkedin API? All answers are welcome!

推荐答案

它链接到两个单独的图像(名称不同).因此,我要做的是查看width和height参数,并查看它们是否正是用来使两个图像看起来不同.因此,第一个图像是100x100,第二个图像是600x200.或者,他们可能使用一张图像,但是尺寸不同.

It is linking to two separate images (the names are not the same). So what I would do is to look at the width and height parameters and see if that is what they are using to make the two images look different. So the first image is say 100x100 but the second is 600x200. Or they might be using one image but the dimensions are different.

我刚刚访问了您提供的链接.请注意以下几点:

I just visited the link you provided. Note the following:

徽标网址

公司徽标的URL,格式为 JPG .

URL for the company logo in JPG format.

您的示例徽标网址表示为 PNG .

Your example logo-url says it is PNG.

使用JPEG(JPG)是因为如果您增加图像的大小,它不会给您造成锯齿.

JPEG(JPG) is used because it doesn't give you jaggies if you increase the size of the image.

更新:U.我正在寻找某种问题,答案就在我眼前.只需打开页面,右键单击大图像,然后从弹出菜单中选择将图像另存为...".由于这样做确实可以为您提供正确的图像,因此,您可能必须每次都抓取HTML源代码以找到正确的图像(如果要对多家公司这样做).

Update: Ugh. I looked for some kind of a problem and the answer was right in front of me. Just bring up the page, right-click on the large image, and select "Save Image As..." from the pop-up menu. Since this DOES get you the right image you may have to scrape the HTML source code to find the right image each time (if you are going to do this for multiple companies).

好的-我花了一段时间重新浏览您显示的网页...

Ok - took me a while to refind the web page you show...

这是一个PHP脚本,它将为您提取较大的徽标.您所要做的就是进入您要从中提取网页的网页:

Here is a PHP script that will extract the larger logo for you. All you have to do is to get TO the web page you need to extract it from:

<?php

    $a = file_get_contents( "ztmt.htm" );
    $a = str_replace( chr(13), "", $a );
    $a = str_replace( "<", "\n<", $a );
    $b = explode( "\n", $a );

    foreach( $b as $k=>$v ){
        if( preg_match("/hero-img/i",$v) ){
            $c = explode( " ", $v );
            foreach( $c as $k1=>$v1 ){
                if( preg_match("/\s+src\s*=/i", $v1) ){
                    $d = explode( "=", $v1);
                    $loc = substr( $d[1], 1, -1 );
                    echo "You can get the image from\n\n$loc\n";
                    }
                }
            }
        }
?>

如您所见,我下载了显示网页的HTML源代码(您可以在PHP的一行中完成此操作),然后将其拉入HTML,将其分解为每行一个HTML命令,查找"hero-img"行,获取该图像的路径,并将其打印出来.

As you can see, I downloaded the HTML source code that displays the web page (you can do that in one line in PHP), it then yanks in the HTML, breaks it up to one HTML command per line, looks for the "hero-img" line, gets the path to that image, and prints it out.

所有您需要做的是编写一些PHP,将您要寻找的公司发送给LinkedIn,转到该网页,删除HTML(file_get_contents也可以这样做),然后让脚本拉动您可以从该网页中获取信息.这并不能解决LinkedIn的错误信息-只是绕过了它.

All you have to do is to write a little PHP that sends what company you are looking for to LinkedIn, go to that web page, suck the HTML off (which file_get_contents will do also), and then let the script yank the information out of that web page for you. This DOES NOT fix LinkedIn's mucked up information - it just bypasses it.

正如我妻子在学校告诉孩子们的那样-当您遇到问题时,搭建一座桥梁并克服它. LinkedIn不会回应-因此,只需从他们的网页上获取您所需的内容即可.

As my wife tells her kids at school - When you come to a problem build a bridge and get over it. LinkedIn won't respond - so just grab what you need off of their web pages.

Hopefull赢得了我的绿色复选标记! :-)

Hopefull this wins me my green checkmark! :-)

顺便说一句:这称为"hero-img"-您是否看过是否有一个名为的标签?只是一个随机的想法.我知道它没有列出-但是LinkedIn可能不如保持文档更新和响应请求一样糟糕. :-/

BTW: This is called "hero-img" - have you looked to see if there is a tag named that? Just a random thought there. I know it isn't listed - but maybe LinkedIn is as bad about keeping their documentation updated as they are about responding to requests. :-/

我还要检查"hero-url",因为其他所有内容都是"-url".只是一个想法.

I'd also check "hero-url" since everything else is "-url". Just a thought.

这篇关于如何从Linkedin API获取公司徽标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆