select json_所有国家/地区的清单:HTML select和JSON

news/2024/7/10 3:01:49 标签: python, java, php, vue, json
select <a class=json" width="403px" height="256px" style="outline: none;" />

select json

Ever needed a list of all the countries in the world to put as options in an HTML select? Well, here you go. And JSON too. You're welcome!

是否曾经需要将世界上所有国家的清单作为option到HTML select ? 好吧,你去。 还有JSON 。 别客气!

但是怎么... (But how...)

How was the list derived so you can update it once in a while? Glad you asked.

列表是如何得出的,以便您可以不时更新一次? 很高兴你问。

https://www.iso.org/obp/ui/#search/code/ is the page linked from W3 spec so it must be the real deal.

https://www.iso.org/obp/ui/#search/code/是从W3规范链接的页面,因此它必须是真实的交易。

Switch to 300 results per page so you can see all the countries.

每页切换到300个结果,以便您可以查看所有国家/地区。

Open console. Write magical ES.OMGWhatNext code:

打开控制台。 编写神奇的ES.OMGWhatNext代码:

Array.from($0.querySelectorAll('tr')).
  map(
    ({cells}) => 
      `<option value="${cells[2].innerText}">${cells[0].innerText}</option>`
  ).join('\n')

Wrap in select, done! Here's how it looks again.

包装select ,完成! 这又是它的样子。

Similarly magical code give you JSON:

同样,神奇的代码为您提供JSON:

JSON.stringify(
  Array.from($0.querySelectorAll('tr')).map(
    ({cells}) => {return {[cells[2].innerText]: cells[0].innerText}}
  )
)

$ 0? ($0?)

One thing to note is the $0 which means the table of results on the ISO page. $0 is what you get when you inspect something in the console and you highlight the inspected DOM node. Instead of $0 you can currently use document.querySelectorAll('table')[2] or document.getElementsByClassName('v-table-table')[0] but who knows how soon the HTML of the page will change.

要注意的一件事是$ 0,它表示ISO页上的结果表。 当您在控制台中检查某些内容并突出显示所检查的DOM节点时,将获得$0 。 您现在可以使用document.querySelectorAll('table')[2]document.getElementsByClassName('v-table-table')[0]代替$ 0,但谁知道页面HTML会多久更改。

Tell your friends about this post on Facebook and Twitter

在Facebook和Twitter上告诉您的朋友有关此帖子的信息

翻译自: https://www.phpied.com/list-of-all-the-countries-html-select-and-json-too/

select json


http://www.niftyadmin.cn/n/1307279.html

相关文章

常见的关系数据库

常见的关系数据库 1、Oracle数据库 Oracle&#xff08;甲骨文&#xff09;公司 2、DB2数据库 IBM公司 3、Sybase数据库 Sybase公司 4、SQL Server数据库 Microsoft公司

发现的乐趣读后感_乐趣:前端性能与后端性能

发现的乐趣读后感Im explaining to .. lets call him "This guy" what I work at Yahoo!: 我正在向..解释&#xff0c;让我们称他为“这个人”&#xff0c;我在Yahoo!工作的内容&#xff1a; [2:10:32 AM] stoyanstefanov says: research, experiments, building too…

在客户端验证时显示提示语句_当仅客户端验证对企业有利时

在客户端验证时显示提示语句the validation. This is a rule, never to be broken. But heres a funny story how skipping the server-side validation actually helped.是验证。 这是一条规则&#xff0c;永不被打破。 但是&#xff0c;这是一个有趣的故事&#xff0c;跳过服…

Oracle版本号的含义

Oracle版本号的含义 Oracle产品版本号由5部分数字组成 1、主发布版本号&#xff1a;是版本的最重要的标识号&#xff0c;表示重大的改进和新的特征 2、主发布维护号&#xff1a;维护版本号&#xff0c;一些新的特性的增加和改进 3、应用服务器版本号&#xff1a;Oracle应用服…

现在可用:Stoyan Stefanov在Amazon.com上发布的“面向对象JavaScript”

I got a nice email from Amazon last week &#x1f642; Unfortunately the book is still missing things like cover image and description, but its a progress! 上周我从亚马逊收到了一封不错的电子邮件&#x1f642;不幸的是&#xff0c;这本书仍然缺少诸如封面图像和描…

Matlab基本函数-ginput函数

1、ginput函数&#xff1a;获取指定点坐标值 2、用法说明 &#xff08;1&#xff09;[x,y] ginput(n) 函数从当前的坐标图上选择n个点&#xff0c;并返回这n个点的相应的坐标向量x、y。n个点可由鼠标定位。用户可以按下回车键在输入n个点之前终止输入&#xff1b; &#xf…

ffmpeg重采样命令_在命令行上制作专辑采样器视频

ffmpeg重采样命令Heres a video I made to raise awareness about Anaconda Limousines first album (where I play guitar and co-wrote 1 song): https://www.youtube.com/watch?v0LavyKbSuvI. This is a post that explains how it was made so if anyone wants to made a …

ie mhtml_MHTML –需要数据时:IE7及以下版本中的URI

ie mhtmlUPDATE: Its very important to have a closing separator in the MHTML document, otherwise there are known issues in IE7 on Vista or Windows 7. The details are here. 更新&#xff1a;在MHTML文档中有一个分隔符非常重要&#xff0c;否则在Vista或Windows 7的…