GVKun编程网logo

在 javascript var 和 jscript 标签内获取 json Python BS4(js获取li标签的value值)

3

本文将带您了解关于在javascriptvar和jscript标签内获取jsonPythonBS4的新内容,同时我们还将为您解释js获取li标签的value值的相关知识,另外,我们还将为您提供关于80

本文将带您了解关于在 javascript var 和 jscript 标签内获取 json Python BS4的新内容,同时我们还将为您解释js获取li标签的value值的相关知识,另外,我们还将为您提供关于800A03EA Microsoft JScript 编译错误、asp.net – 在哪里可以下载DLR的Managed JScript?、Bash shell 中的 ${var}、"$var" 和 "${var}" 有什么区别?、Bash shell中的${var},“$var”和“${var}”有什么区别?的实用信息。

本文目录一览:

在 javascript var 和 jscript 标签内获取 json Python BS4(js获取li标签的value值)

在 javascript var 和 jscript 标签内获取 json Python BS4(js获取li标签的value值)

如何解决在 javascript var 和 jscript 标签内获取 json Python BS4

我需要将 json 放在一个 java 脚本变量中,并将它放在这样的脚本标记中

  1. <script type="text/javascript">

但它不是 HTML 中唯一的 type="text/javascript",标签是 netx:

  1. <script type="text/javascript">
  2. var products = ''{"id":"000000000000193758","name":"FZ1292","estilo":"FZ1292","date":"44348","month":"JUNIO","day":"1","regster":"","price":"3499","name2":"McDonalds x Harden Vol. 5 ","description":"Detén tu hambre por jugar básquetbol ","image":"www.somesite.com":"ADIDAS","realdate":"06-01-2021"}
  3. </script>

我尝试了以下方法:

  1. script = soup.find_all(''script'',{''type'': ''text/javascript''})

但是它带来了所有匹配的标签,我不知道如何识别具体的标签,因为它没有id

解决方法

beautifulsoup 无法解析 javascript,但您可以使用 re/json 模块解析数据。例如:

  1. import re
  2. import json
  3. html_doc = """
  4. <script type="text/javascript">
  5. var products = ''{"id":"000000000000193758","name":"FZ1292","estilo":"FZ1292","date":"44348","month":"JUNIO","day":"1","regster":"","price":"3499","name2":"McDonalds x Harden Vol. 5 ","description":"Detén tu hambre por jugar básquetbol ","image":"www.somesite.com/ADIDAS","realdate":"06-01-2021"}''
  6. </script>
  7. """
  8. products = re.search(r"products = ''(.*)''",html_doc).group(1)
  9. products = json.loads(products)
  10. # pretty print the data:
  11. print(json.dumps(products,indent=4))

打印:

  1. {
  2. "id": "000000000000193758","name": "FZ1292","estilo": "FZ1292","date": "44348","month": "JUNIO","day": "1","regster": "","price": "3499","name2": "McDonalds x Harden Vol. 5 ","description": "Det\\u00e9n tu hambre por jugar b\\u00e1squetbol ","image": "www.somesite.com/ADIDAS","realdate": "06-01-2021"
  3. }

800A03EA Microsoft JScript 编译错误

800A03EA Microsoft JScript 编译错误

如何解决800A03EA Microsoft JScript 编译错误?

我正在按照最后的步骤为我正在遵循的指南创建后端服务器。 Link。我已经下载了 Node.js,但我一直遇到这个我无法克服的错误。

这里是 index.js 的代码

 // import dependencies
    const express = require(''express'');
    const bodyParser = require(''body-parser'');
    const path = require(''path'');
    const Pusher = require(''pusher'');
    const PushNotifications = require(''@pusher/push-notifications-server'');

    // initialise express
    const app = express();
    const pusher = new Pusher(require(''./config.js''));
    const pushNotifications = new PushNotifications(require(''./config.js''))

    function handleStock(req,res,stock) {
        let loopCount = 0;

        let sendToPusher = setInterval(() => {
            loopCount++;
            const changePercent = randomIntFromInterval(-10,10)
            const currentValue  = randomIntFromInterval(2000,20000);        
            const stockName = (stock === ''amazon'') ? ''Amazon'' : ''LoanDepot''
            const price = currentValue.toString()

            // Send to pusher
            pusher.trigger(''stock-channel'',stockName,{currentValue,changePercent})

            pushNotifications.publish(
                [''stocks''],{
                fcm: {
                  notification: {
                    title: stockName,body: `The new value for ${stockName} is: ${price}`
                  }
                }
              }).then((publishResponse) => {
                console.log(''Just published:'',publishResponse.publishId);
              });

            if (loopCount === 5) {
              clearInterval(sendToPusher)
            }
        },2000);

        res.json({success: 200})
    }

    app.get(''/stock/amazon'',(req,res) => handleStock(req,''amazon''));
    app.get(''/stock/apple'',''apple''));

    function randomIntFromInterval(min,max) {
        return Math.floor(Math.random()*(max-min+1)+min);
    }

    const port = 5000;

    app.listen(port,() => console.log(`Server is running on port ${port}`));

更新:这是错误

Script:  C:\Practical Android\StockExchangeApp\files\index.js
Line: 2
Char: 5
Error: Syntax error
Code: 800A03EA
Source: Microsoft JScript compilation error

我忽略了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

asp.net – 在哪里可以下载DLR的Managed JScript?

asp.net – 在哪里可以下载DLR的Managed JScript?

动态语言运行时的最新版本(0.9稳定版)包含IronPython和IronRuby,但它不包含Managed JScript.

有谁知道我可以在哪里下载最新版本的Managed JScript以用于ASP.NET和/或WPF?

如果您不知道,JScript.NET和Managed JScript是完全不同的东西.我正在寻找的是Managed JScript.

解决方法

更新中…

Silverlight动态语言SDK 0.5.0 Release Notes于2009年3月23日发布于CodePlex,包含了这个小宝石:

Managed JScript has been removed from
the package.

当在this thread中询问Managed JScript(Ironjscript)的未来时,Dynamic Language Runtime论坛的协调员Bill(billchi)有以下说法:

The DLR JScript was experimental for
informing the design of the DLR
(expression trees,interop,callsites,
hosting,etc.). The JS we released
with asp futures and the Silverlight
dynamic sdk became very old and
unserviceable as the DLR continued
evolving for release in CLR 4.0.
Unfortunately,there are no plans at
this time to develop and release a
DLR-hostable JScript.

Thanks,

Bill

(编辑以添加后期帖子的引用)

The JScript team will continue
supporting using native Jscript
(jscript.dll) with IActiveScript.
They’ll also continue to service
Jscript.NET,but they aren’t making
other commitments at this point.

Bill

考虑到JScript.NET脚本API现在已经过时(尽管它们仍然存在于.NET 2.0中),因此似乎没有从JScript(JavaScript)的ActiveScripting实现中获得.NET升级路径.

我可以建议讨论(抗议;-)指向that thread.

Bash shell 中的 ${var}、

Bash shell 中的 ${var}、"$var" 和 "${var}" 有什么区别?

标题说什么:将变量封装在 , 或 ” 中是什么意思{}"""{}无法在网上找到任何关于此的解释 -
除了使用符号外,我无法参考它们,其中不产生任何东西。

这是一个例子:

declare -a groupsgroups+=("CN=exampleexample,OU=exampleexample,OU=exampleexample,DC=example,DC=com")groups+=("CN=example example,OU=example example,OU=example example,DC=example,DC=com")

这个:

for group in "${groups[@]}"; do    echo $groupdone

事实证明与此有很大不同:

for group in $groups; do    echo $groupdone

和这个:

for group in ${groups}; do    echo $groupdone

只有第一个完成了我想要的:遍历数组中的每个元素。我不太清楚$groups,"$groups"和之间${groups}的区别"${groups}"。如果有人能解释一下,我将不胜感激。

作为一个额外的问题 - 有没有人知道引用这些封装的公认方式?

答案1

小编典典

大括号($varvs. ${var}

在大多数情况下,$var${var}是相同的:

var=fooecho $var# fooecho ${var}# foo

大括号仅用于解决表达式中的歧义:

var=fooecho $varbar# Prints nothing because there is no variable ''varbar''echo ${var}bar# foobar

行情($var对比"$var"对比"${var}"

当您在变量周围添加双引号时,您告诉 shell 将其视为一个单词,即使它包含空格:

var="foo bar"for i in "$var"; do # Expands to ''for i in "foo bar"; do...''    echo $i         #   so only runs the loop oncedone# foo bar

将该行为与以下内容进行对比:

var="foo bar"for i in $var; do # Expands to ''for i in foo bar; do...''    echo $i       #   so runs the loop twice, once for each argumentdone# foo# bar

$varvs.一样${var},大括号仅用于消歧,例如:

var="foo bar"for i in "$varbar"; do # Expands to ''for i in ""; do...'' since there is no    echo $i            #   variable named ''varbar'', so loop runs once anddone                   #   prints nothing (actually "")var="foo bar"for i in "${var}bar"; do # Expands to ''for i in "foo barbar"; do...''    echo $i              #   so runs the loop oncedone# foo barbar

请注意,"${var}bar"在上面的第二个示例中也可以编写"${var}"bar,在这种情况下,您不再需要大括号,即"$var"bar.
但是,如果您的字符串中有很多引号,则这些替代形式可能难以阅读(因此难以维护)。这个页面很好地介绍了 Bash 中的引用。

数组($var对比$var[@]对比${var[@]}

现在为您的阵列。根据bash手册:

引用不带下标的数组变量等价于引用下标为 0 的数组。

换句话说,如果你不提供索引[],你会得到数组的第一个元素:

foo=(a b c)echo $foo# a

这与

foo=(a b c)echo ${foo}# a

要获取数组的所有元素,您需要将其@用作索引,例如${foo[@]}. 数组需要大括号,因为没有它们,shell
$foo首先扩展该部分,给出数组的第一个元素,后跟一个文字[@]

foo=(a b c)echo ${foo[@]}# a b cecho $foo[@]# a[@]

这个页面很好地介绍了
Bash 中的数组。

重温行情(${foo[@]}对比"${foo[@]}"

您没有问过这个问题,但这是一个很好了解的细微差别。如果数组中的元素可能包含空格,则需要使用双引号,以便将每个元素视为单独的“单词:”

foo=("the first" "the second")for i in "${foo[@]}"; do # Expands to ''for i in "the first" "the second"; do...''    echo $i              #   so the loop runs twicedone# the first# the second

将此与不带双引号的行为进行对比:

foo=("the first" "the second")for i in ${foo[@]}; do # Expands to ''for i in the first the second; do...''    echo $i            #   so the loop runs four times!done# the# first# the# second

Bash shell中的${var},“$var”和“${var}”有什么区别?

Bash shell中的${var},“$var”和“${var}”有什么区别?

标题说:在{},“”或“{}”中封装一个变量是什么意思?我没有能够在网上找到任何解释 – 我没有能够参考他们,除了使用符号,这不产生任何东西。

这里有一个例子:

declare -a groups

groups+=("CN=exampleexample,OU=exampleexample,DC=example,DC=com")
groups+=("CN=example example,OU=example example,DC=com")

这个:

for group in "${groups[@]}"; do
    echo $group
done

证明与此有很大的不同:

for group in $groups; do
    echo $group
done

和这个:

for group in ${groups}; do
    echo $group
done

只有第一个完成我想要的:遍历数组中的每个元素。我不太清楚$ groups,“$ groups”,$ {groups}和“$ {groups}”之间的区别。如果有人能解释它,我会很感激。

作为一个额外的问题 – 有没有人知道接受的方式来引用这些封装?

大括号($ var vs. $ {var})

在大多数情况下,$ var和$ {var}是相同的:

var=foo
echo $var
# foo
echo ${var}
# foo

大括号只需要解决表达式中的歧义:

var=foo
echo $varbar
# Prints nothing because there is no variable 'varbar'
echo ${var}bar
# foobar

引用($ var vs.“$ var”vs.“$ {var}”)

当你在变量上加上双引号时,你可以告诉shell把它当作一个单词,即使它包含空格:

var="foo bar"
for i in "$var"; do # Expands to 'for i in "foo bar"; do...'
    echo $i         #   so only runs the loop once
done
# foo bar

对比与以下行为:

var="foo bar"
for i in $var; do # Expands to 'for i in foo bar; do...'
    echo $i       #   so runs the loop twice,once for each argument
done
# foo
# bar

与$ var vs. $ {var}一样,大括号只需要消除歧义,例如:

var="foo bar"
for i in "$varbar"; do # Expands to 'for i in ""; do...' since there is no
    echo $i            #   variable named 'varbar',so loop runs once and
done                   #   prints nothing (actually "")

var="foo bar"
for i in "${var}bar"; do # Expands to 'for i in "foo barbar"; do...'
    echo $i              #   so runs the loop once
done
# foo barbar

注意,上面第二个例子中的“$ {var} bar”也可以写成“$ {var}”bar,在这种情况下你不再需要大括号,即“$ var”bar。但是,如果你的字符串中有很多引号,这些替代形式可能很难阅读(因此很难维护)。 This page提供了在Bash中引用的一个很好的介绍。

数组($ var vs. $ var [@] vs. $ {var [@]})

现在为你的数组。根据bash manual:

Referencing an array variable without a subscript is equivalent to referencing the array with a subscript of 0.

换句话说,如果你不使用[]提供索引,你会得到数组的第一个元素:

foo=(a b c)
echo $foo
# a

这是完全一样的

foo=(a b c)
echo ${foo}
# a

要获取数组的所有元素,您需要使用@作为索引,例如。 $ {foo [@]}。大括号是数组必需的,因为没有它们,shell会首先展开$ foo部分,给出数组的第一个元素,后面跟一个文字[@]:

foo=(a b c)
echo ${foo[@]}
# a b c
echo $foo[@]
# a[@]

This page是Bash中数组的一个很好的介绍。

重新查看的报价($ {foo [@]}与“$ {foo [@]}”)

你没有问这个,但它是一个微妙的差别,是很好知道。如果数组中的元素可以包含空格,则需要使用双引号,以便将每个元素视为单独的“word:”。

foo=("the first" "the second")
for i in "${foo[@]}"; do # Expands to 'for i in "the first" "the second"; do...'
    echo $i              #   so the loop runs twice
done
# the first
# the second

与没有双引号的行为对比:

foo=("the first" "the second")
for i in ${foo[@]}; do # Expands to 'for i in the first the second; do...'
    echo $i            #   so the loop runs four times!
done
# the
# first
# the
# second

今天的关于在 javascript var 和 jscript 标签内获取 json Python BS4js获取li标签的value值的分享已经结束,谢谢您的关注,如果想了解更多关于800A03EA Microsoft JScript 编译错误、asp.net – 在哪里可以下载DLR的Managed JScript?、Bash shell 中的 ${var}、"$var" 和 "${var}" 有什么区别?、Bash shell中的${var},“$var”和“${var}”有什么区别?的相关知识,请在本站进行查询。

本文标签: