Tag: html

如何使用jquery和selenium在'chrome:// downloads'下访问`shadow-root`下的元素?

我想在我的seleniumJavaScript应用程序中获取最后下载的文件的名称。 我有我的selenium驱动程序导航到铬下载页面使用: driver.get('chrome://downloads'); ,但是当我到达那里时,selenium在下载页面上无法find任何元素。 Chrome下载页面“chrome:// downloads”有一堆shadow-root元素,我不知道如何获取下面的内容以访问我想要的id。 如何访问shadow-root项目下的标识符? 我想获得$(“#文件链接”)如下所示: 但是,当我使用jQuery来find它,一切都返回null(可能是因为它是在shadow-root后面) 下面是我所有的信息的全貌,包括显示“#file-link”完全存在: 我用来等待元素存在的代码与我在应用程序中使用的所有元素相同,所以我认为这已经在工作: driver.wait(until.elementLocated(By.id('downloads-manager')), 120000).then(function(){ console.log("#downloads-manager shows"); driver.findElement(By.id('downloads-manager')).then(function(dwMan){ //How do I "open" #shadow-root now? 🙁 }); }); 这是我的版本信息: Chromium v​​54.0.2840.71 节点v6.5.0 ChromeDriver v2.27.440175 selenium-Webdriver v3.4.0 类似的问题 seleniumwebdriver找不到铬://下载 (这是我有,但在Python中相同的问题) 链接 Selenium JavaScript API: https : //seleniumhq.github.io/selenium/docs/api/javascript/

无法将图像保存到插件中

我没有太多关于撇号的知识,但我试图创build一个自定义小部件。 我想在我的小部件中有三个字段: 标题(string) 描述(string) 一个图像 我还没有find一种方法来添加一个图像的小部件作为领域。 现在,我在窗口小部件中添加了一个单例,它工作正常。 但是当添加一个图像时,它会显示在页面上,但是当我重新加载页面时,图像不见了。 我的widget.html代码 <div class="md-jumbotron"> <div class="md-grid"> <h1>{{ data.widget.heading }}</h1> <h6>{{ data.widget.desc }}</h6> <div class="img"> {{ apos.singleton(data.page, 'jumbotroPic', 'apostrophe-images', { limit: 1, size: 'full' }) }} </div> </div> 我在控制台上得到了以下内容 $ node app.js WARNING: No session secret provided, please set the `secret` property of the `session` property of the apostrophe-express […]

HTML表单请求主体为空 – NodeJs

我正在使用Node.js创build一个API POST并expression。 我只是想使用HTML格式发布一些数据: <form id="myform" action="http://localhost:4000/add" method="post" enctype="application/json"> <input type="text" name="name" id="name" /> <input type="submit" id="submit" /> </form> 服务器只会收到POST请求,并将主体显示到console.log中。 router.post('/add', function (req, res){ console.log("request: "+JSON.stringify(req.body)); }) 在控制台上收到的是:request:{} 试图张贴到相同的API使用邮递员 – 原始,JSON(应用程序/ JSON),事情工作正常。 有人可以告诉我什么是我在做什么错?

如何使用express和angular 2(打字稿)在待办事项列表中编辑标题

我使用express和Angular 2 – todo列表在web上创build我的第一个应用程序。 现在我有事件来添加新的任务,删除和更改checkbox,但我不知道如何编辑标题通过点击,例如,项目或button上的“ 编辑 ”。 Task.ts export class Task{ title: string; isDone: boolean; } 文件html tasks.component.html <div *ngFor="let task of tasks" class="todo"> <button class="delete icon"> <i class="material-icons">delete</i> </button> <button class="checkbox icon" (click)="updateStatus(task)"> <i class="material-icons">{{task.isDone ? 'check_box' : 'check_box_outline_blank' }}</i> </button> <span class = "title"> {{task.title}}</span> <div class="actions" (click)="deleteTask(task._id)"> <button class="delete icon"> <i class="material-icons">delete</i> […]

node.jsparsinghtml文本以获得一个javascriptvariables的值

我成功地做到这一点,以获得我感兴趣的页面的帮助文本。 router.get('/get', function (req, res) { var pg = 'https://j……com/f/resource' console.log('get', pg); requestify.get(pg).then(function (resp) { console.log(resp.body); }); }); 现在,我有页面的文本,我想parsing文本来获取我知道存在于文本中的JavaScriptvariables的值。 <script> var x1 = {"p": {…….bla bla …}};</script> 我知道有时<script>标签将包含type属性; 但并不总是包含type属性。 当我findx1的值时,我在javascript的应用程序中将myVarvariables中的值用于什么目的。 如果你没有答案,那么你对我应该研究什么的评论/提示是值得赞赏的。 我希望我会find一些模块,我可以把整个文本,并有模块以某种方式只是输出所有variables为我的值。

无法使用Cheerio获取iframe

您好,我正在试图从wathfree.to获得一个iframe。 这是我用于这个目的的代码: function getSecondBody(url2) { url2 = 'http://www.watchfree.to/watch-366-Forrest-Gump-movie-online-free-putlocker.html'; request(url2, function(err, resp, body) { var $ = cheerio.load(body); var embedcode = $('.links_left_container'); embedcodetext2 = embedcode.html(); console.log(embedcodetext2); return embedcodetext2; }); } 但返回的响应不包含我需要的iframe。 这是我收到的回应: 而实际的页面如下所示: 我的回复中只有iframe部分丢失。

使用NodeJS从外部页面返回Javascript可变数据

我试图发送一个请求到一个页面,并抓住整个DOM。 基本上爬行。 在这个网站上,有一个variables直接加载到HTML(不是一个脚本文件)与一些数据。 使用我使用request NodeJS后端,我将如何请求这个页面并返回variables的数据? 这是一个例子: http://some-page.com/index.html <html> <head> <script> var my_var = { title: "Good title", description: "Nice description", page: 5 }; </script> </head> </html> 如果我访问网站,打开控制台并键入my_var我可以看到控制台中的内容,所以这是一个全局variables。 我怎么能做这样的事情? 如果需要,我可以使用另一个请求库。

对于React组件,<img>中的.jpg模块parsing失败?

我想在我的网站上显示一个图像,我正在使用反应。 这里是组件源代码: import React, { Component } from 'react'; import style from './styles/AboutMeStyle.css'; export default class AboutMe extends Component{ render(){ return ( <div> <img src={require ('./images/ProfilePic.jpg')}align="middle"/> </div> ); } } 该文件似乎被发现,但我不断收到一个exception,说明模块parsing失败…? 这里是来自terminal的错误的文本输出: Module parse failed: /Users/megan/Desktop/Personal Website/client/components/images/ProfilePic.jpg Unexpected character (1:0) You may need an appropriate loader to handle this file type. SyntaxError: Unexpected character (1:0) […]

如何使用下载的纱线依赖关系

这可能是一个非常愚蠢的问题,但如果你能帮助我的话,那将是非常棒的。 这是问题:我已经添加了一个包到我的项目。 它包含一些我想在我的HTML文件中使用的CSS文件等。 我已经使用yarn add <package>添加了它。 这些文件位于/node_modules/semantic-ui-css/semantic.min.css 。 我必须引用完整的node_modulepath来加载我的HTML文件中的CSS文件? 这听起来不对。 在我使用包pipe理器之前,我只是下载了一些css文件,将它们放到/vendor/css/并使用它们。 或者现在正常使用<link rel="stylesheet" type="text/css" href="node_modules/semantic-ui-css/semantic.min.css"> ?

如何不断更新从JS服务器的数据?

有数据不断更新在服务器上,并写入文件(每100毫秒),我需要将其转移到客户端,目前我通过setInterval函数(这应该检查它们在相同的间隔),检查这个JSON文件,我不知道这是否是一个正确的解决scheme的问题。 服务器端代码: function SerialPortStart(COM, Input){ console.log( COM, Input); var serialPort = new SerialPort(COM, { parser: SerialPort.parsers.readline('\n'), baudrate: +Input || 9600 }); serialPort.on('data', function (data) { thermodata = data.toString(); console.log(data); fs.writeFileSync(__dirname +'/views/cockpit.json',JSON.stringify(thermodata)); }); }; 客户端代码: function SerialPortStart(){ var xhr = new XMLHttpRequest(); setInterval(function() { xhr.open('GET', 'cockpit.json', true); xhr.send(); xhr.onreadystatechange = function() { if(this.status == 200) { […]