exists

Python check if website exists

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I wanted to check if a certain website exists, this is what I'm doing: user_agent = 'Mozilla/20.0.1 (compatible; MSIE 5.5; Windows NT)' headers = { 'User-Agent':user_agent } link = "http://www.abc.com" req = urllib2.Request(link, headers = headers) page = urllib2.urlopen(req).read() - ERROR 402 generated here! If the page doesn't exist (error 402, or whatever other errors), what can I do in the page = ... line to make sure that the page I'm reading does exit? 回答1: You can use HEAD request instead of GET. It will only download the header, but

Check if html element exists with iMacros and javascript

匿名 (未验证) 提交于 2019-12-03 02:33:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want to check if an HTML element exist with iMacros. If it does, I want to go to a URL. If not, I want to go to other URL. Because iMacros doesn't have statements, I used javascript with the iMacros' EVAL. Here is the line that handles the javascript execution: SET !VAR3 EVAL("var element = window.content.document.getElementById(\"some_element\"); if (typeof(element) != 'undefined' && element != null) { var redirect = 'http://192.168.178.22/sc/report.php'; } else { var redirect = 'http://192.168.178.22/sc/index.php?action=connect'; }

ImageTag exists in the TR?

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: EDIT: public bool getImage () { IWebElement table = driver . FindElement ( By . Id ( "DIV_ID_1" )); string name = String . Format ( "//*[contains(text(), \'{0}\')]" , 'TEST1' ); IWebElement element = table . FindElement ( By . XPath ( name )); IWebElement parent = element . FindElement ( By . XPath ( ".." )); try { IWebElement image = element . FindElement ( By . XPath ( "//img" )); } catch ( NoSuchElementException e ) { return false ; } return true ; } How would I find out if the TEST1 does have Image ? in the below html source

Creating temporary folders

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am working on a program that needs to create a multiple temporary folders for the application. These will not be seen by the user. The app is written in VB.net. I can think of a few ways to do it such as incremental folder name or random numbered folder names, but I was wondering, how other people solve this problem? 回答1: Update: Added File.Exists check per comment (2012-Jun-19) Here's what I've used in VB.NET. Essentially the same as presented, except I usually didn't want to create the folder immediately. The advantage to use

SQLite check if a row exists

匿名 (未验证) 提交于 2019-12-03 02:31:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm trying to check if a specific ID exists in a table named "Products" in my sqlite database. def existsCheck( db, id ) temp = db.execute( "select exists( select 1 from Products where promoID = ? ) ", [id] ) end that's my current code but that returns an array which means I have to deal with conversion before I can use it as a boolean. Any ideas how I can change it so that it returns an int with the value 1? 回答1: There is no need to use a subquery: def existsCheck( db, id ) db.execute( "select 1 from Products where promoID = ?", [id] )

Error: Tablespace for table xxx exists. Please DISCARD the tablespace before IMPORT

匿名 (未验证) 提交于 2019-12-03 02:30:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am fairly new to MySQL and I am getting a pretty interesting error on which I cannot find any help via google and the stackoverflow search. I am running a local server of MySQL 5.6.10 on MacOS 10.8.3 and manage my database via Navicat essentials for MySQL. The error I get is that after running and managing my database just fine for a couple of days/weeks something triggers to (it appears incompletely) delete some of the tables I created using queries from within Navicat. When I try to run queries using these tables, Navicat then warns me

Dropping procedure which already exists? [duplicate]

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Possible Duplicate: Error with mysql procedures ERROR 1304 & ERROR 1305 I try to run a command to drop a procedure: DROP PROCEDURE create_datetable By doing this I get the a warning: 1304 PROCEDURE create_datetable already exists After that when I'm trying to create a new procedure with the same name, I get the same warning. What does this mean? 回答1: Reference: Drop Procedure . The code: DROP PROCEDURE IF EXISTS procedureName; ... Edit: Can you try to rename the procedure and then try to drop it as per this post: Rename a mysql procedure ?

Playing multiple video using libvlc and Qt

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have created a sample application in Qt where i have to display camera stream in a 2x2 grid. I am using libvlc to play the stream and i am able to display the video as well. But i am facing few issues Vlc is creating a separate window to render the video. Its not displayed on the area provided by Qt Application. Here is my code void playerView::createPlayer() { const char *const vlc_args[] = { "--avcodec-hw=any", "--plugin-path=C:\QtSDK\vlc-2.2.1\plugins" }; vlcinstance = libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args); const

Twitter API: Url search for Username

匿名 (未验证) 提交于 2019-12-03 02:29:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have a list of websites where I want to see if they have twitter accounts. I was curious if there is a url search for username in the API, or something of this nature. I've been reading and looking around; however, I've come up short. I would hate to have to do this manually when I could run a function to do the work for me. Would greatly appreciate some feedback on this topic. Good day! 回答1: As explained in the comment above, version 1 of the twitter API is deprecated and will soon be removed completely. This means that simple requests

Warning: filesize(): stat failed for img.jpg

匿名 (未验证) 提交于 2019-12-03 02:26:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to get the file size of an image and I keep getting Warning: filesize(): stat failed for img.jpg This is what I did: $path = $_FILES['profile']['name']; $path = iconv('UTF-8', 'ISO-8859-1',$path); if (!in_array(pathinfo($path,PATHINFO_EXTENSION),$allowed)) { return "file"; } elseif (filesize($path)>(1024*600)) I am able to get the file extension no problem but the filesize() just doesn't seem to work. I have been reading a bit and did find this but it did not solve the problem. Any help is much appreciated! 回答1: ['name'] in the $