Search Results

Search found 21350 results on 854 pages for 'url parsing'.

Page 72/854 | < Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >

  • Parsing and validating arbitrary date formats in ruby (on rails)

    - by Matt Briggs
    I have a requirement to handle custom date formats in an existing app. The idea is that the users have to do with multiple formats from outside sources they have very little control over. We will need to be able to take the format and both validate Dates against it, as well as parse strings specifically in that format. The other thing is that these can be completely arbitrary, like JA == January, FE == February, etc... to my understanding, chronic only handles parsing (and does it in a more magical way then I can use), and enter code here DateTime#strptime comes close, but doesn't really handle the whole two character month scenario, even with custom formatters. The 'nuclear' option is to write in custom support for edge cases like this, but I would prefer to use a library if something like this exists.

    Read the article

  • Searching algorithmics: Parsing and processing a request

    - by James P.
    Say you were to create a search engine that can accept a query statement under the form of a String. The statement can be used to retrieve different types of objects with a given set of characteristics and possibly linked to other objects. In plain english or pseudo-code using an OOP approach, how would you go about parsing and processing statements as follows to get the series of desired objects ? get fruit with colour green get variety of apples, pears from Andy get strawberry with colour "deep red" and origin not Spain get total of sales of melons between 2010-10-10 and 2010-12-30 get last deliverydate of bananas from "Pete" and state not sold Hope the question is clear. If not I'll be more than happy to reformulate. P.S: This isn't homework ;)

    Read the article

  • golang dynamically parsing files

    - by Brian Voelker
    For parsing files i have setup a variable for template.ParseFiles and i currently have to manually set each file. Two things: How would i be able to walk through a main folder and a multitude of subfolders and automatically add them to ParseFiles so i dont have to manually add each file individually? How would i be able to call a file with the same name in a subfolder because currently I get an error at runtime if i add same name file in ParseFiles. var templates = template.Must(template.ParseFiles( "index.html", // main file "subfolder/index.html" // subfolder with same filename errors on runtime "includes/header.html", "includes/footer.html", )) func main() { // Walk and ParseFiles filepath.Walk("files", func(path string, info os.FileInfo, err error) { if !info.IsDir() { // Add path to ParseFiles } return }) http.HandleFunc("/", home) http.ListenAndServe(":8080", nil) } func home(w http.ResponseWriter, r *http.Request) { render(w, "index.html") } func render(w http.ResponseWriter, tmpl string) { err := templates.ExecuteTemplate(w, tmpl, nil) if err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) } }

    Read the article

  • Sax parsing from web service

    - by donald
    Hey, I am trying to parse xml file using Sax parser. let's say xml is like this.. I want to count the number of times b element is present (its variable) And i want this count before parsing, so that I can declare an array of appropriate size. One way is to run count then separately and other way is dynamic array (List Array) Is there any other better way to do this? Also, Is it possible to make an ArrayList of my class..? because I want an array of type myClass.

    Read the article

  • JasperReports reports access image via authenticated URL

    - by user363115
    Hi all, I am hoping that this is a simple issue with a simple solution and that I have missed something obvious. Let me explain the problem; We have an application that generates PDF reports (using Jasper). These reports contain data from our database, as well as imagery (photographs). These photographs are stored in S3. We use signed URLs to access these photographs. We link these photographs into our Jasper reports using these S3 URLs. Because the S3 URLs are signed and time-limited (by design), the process is as follows; User requests a report to be generated, Report is filled, and goes to our database (at which time UUIDs to any required images are retrieved), For each UUID an S3 signed URL must be generated, To do this the URL behind each report image is a call to an authenticated URL in our app (/get_img?uuid=foo), The controller behind this URL generates a signed S3 URL and returns it, Reports loads the image. The problem is with step (4) - the call to the authenticated URL fails because Jasper does not pass any authentication information with the request. Is there a solution here? Thanks all for your time. Ben

    Read the article

  • App-Engine Parse a UrlFetch UTF-8 encoded stream

    - by Davidrd91
    I am trying to parse an XML from a URL using the xml.sax parser. I know there are other libraries to use but coming from Java this is the one I am most familiar with and seems the least complicated to me. The code I'm using to parse is as follows: parser = xml.sax.make_parser() handler = MangaHandler() parser.setContentHandler(handler) url = urlfetch.Fetch('http://www.mangapanda.com/alphabetical', allow_truncated = False, follow_redirects = False, deadline = False) xml.sax.parseString(url.content, handler) This returns a SaxException (invalid token) once the parser reaches the first & sign: SAXParseException: <unknown>:582:34: not well-formed (invalid token) Because urlfetch returns a string and not a stream I cannot use the parse() (which only works with streams) and am left to use parseString() instead. To see if parsing as a stream would fix this I tried: parser.parse(io.StringIO(url.content).encode('utf-8')) but this returns: TypeError: initial_value must be unicode or None, not str I have also tried to use the urllib2 libraries which do return a stream instead of urlfetch but the file is too large and is automatically truncated, leaving me with missing data. Any Sort of work-around for this would be greatly appreciated as I've spent days getting around one obstacle just to be stopped by another.

    Read the article

  • How to handle building and parsing HTTP URL's / URI's / paths in Perl

    - by Robert S. Barnes
    I have a wget like script which downloads a page and then retrieves all the files linked in img tags on that page. Given the URL of the original page and the the link extracted from the img tag in that page I need to build the URL for the image file I want to retrieve. Currently I use a function I wrote: sub build_url { my ( $base, $path ) = @_; # if the path is absolute just prepend the domain to it if ($path =~ /^\//) { ($base) = $base =~ /^(?:http:\/\/)?(\w+(?:\.\w+)+)/; return "$base$path"; } my @base = split '/', $base; my @path = split '/', $path; # remove a trailing filename pop @base if $base =~ /[[:alnum:]]+\/[\w\d]+\.[\w]+$/; # check for relative paths my $relcount = $path =~ /(\.\.\/)/g; while ( $relcount-- ) { pop @base; shift @path; } return join '/', @base, @path; } The thing is, I'm surely not the first person solving this problem, and in fact it's such a general problem that I assume there must be some better, more standard way of dealing with it, using either a core module or something from CPAN - although via a core module is preferable. I was thinking about File::Spec but wasn't sure if it has all the functionality I would need.

    Read the article

  • parsing xml attribute value

    - by vbNewbie
    I have been parsing xml content using the xmlreader and cannot use the xml document but so far it works getting all elementcontent except for the attribute contents. I need to parse the link below found in the following entry; <title>XXXX UUUUUU posted a</title> <category term="NotePosted" label="Note Posted"/> <link rel="alternate" type="html" href="http://www.dfsddsfdsf.com/profile.php?id=sdfdfsfdsdfddfsfd&amp;v=wall&amp;story_dbid=dssdfasdfdasfdsafafafa"/> <source>......... <source> I need the href tag in the link attribute but it keeps coming back null. While ureader.Read If ureader.HasAttributes Then fId = ureader.GetAttribute("href") If fId.Contains("?v=wall&amp") Then fIdList.Add(fId) Exit While End If If String.IsNullOrEmpty(fId) Then fId = "NOTHING" End If End If End While

    Read the article

  • XML Parsing Error: no element found

    - by Anilkumar
    XML Parsing Error: no element found Line Number 1, Column 1: I want to download a Excel file. I wrote the data in a html table format and appending to the response. The code is following : Response.Buffer = false; Response.Expires = 0; Response.Clear(); Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment; filename=" + FileName); Response.Write(str); Response.End();

    Read the article

  • How to use .htaccess to redirect to an url that includes a query parameter

    - by wbervoets
    Hi guys, I've been struggling with a redirect where the final URL includes a query parameter that is an URL. It seems htaccess is escaping some characters. Here is my htaccess: Code: RewriteRule ^mypath http s://www.otherserver.com/cookie?param1=123&redirectto=http://otherserver2.com/&param2=1 [L,R=302] First, if I put Code: http s://www.otherserver.com/cookie?param1=123&redirectto=http://otherserver2.com/&param2=1 in my browser address bar, www.otherserver.com will do its thing and then redirect to otherserver2 (including the &param2=1 which is a parameter of that URL and not of the URL otherserver.com) That's the behaviour I need :-) Now when I try to use the htaccess redirect from my site: http://mysite/mypath; the behaviour is not the same then putting the same URL in the browser address bar; it now tries to redirect to http ://otherserver2.com/ (no param2=1 anymore). (ps: otherserver1 and otherserver2 are not under my control.) I've tried escaping the redirectto parameter in my htaccess, like below, but it didn't work either: Code: http s://www.otherserver.com/cookie?param1=123&redirectto=http%3a%2f%otherserver2.com%2f%3fparam2%3d1 Because then my browser tries to go to httpotherserver.com (all special characters are gone) In the end I would like to see http ://mysite/mypath to show the contents of Code: http s://www.otherserver.com/cookie?param1=123&redirectto=http://otherserver2.com/&param2=1 (preferred solution) or do a redirect to that URL. I hope my message is not to confusing, I hope someone can help me out; as I've already spent hours on this :-)

    Read the article

  • Having trouble parsing itunes affiliate xml...

    - by MKDev
    Hi, I am trying to parse an itunes affiliate xml link purely for practise, using NSXMLParser but the link will not parse. The itunes affiliate xml link is this: http://itunes.apple.com/au/rss/topsongs/limit=50/genre=20/xml?partnerId=2003&TD_PARAM=http%3A%2F%2Fclkuk.tradedoubler.com%2Fclick%3Fp%3D23708%26a%3D1904172%26url%3D. it works perfectly in safari on my mac. The normal itunes link I tried parsing: http://itunes.apple.com/%@/rss/%@/limit=50/genre=20/xml works perfectly with the NSXMLParser. Can anyone tell me why this is happening? Thanks in advanced. MKDev

    Read the article

  • Remove newline character while XML parsing

    - by Prashant
    Hi, I am facing a problem while XML parsing. I have an NSMutablestring currentElementValue that has newlines into it. It has been received as an XMl from a web source. Even when i am trying to remove newline charactersets of substring the first 3 char there is no effect on the string. What can be done here? Regards PC Code is (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { if(!currentElementValue) currentElementValue = [[NSMutableString alloc] initWithString:string]; else { [currentElementValue substringFromIndex:3]; [currentElementValue stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; NSLog(@"Processing Value : %@ with length %d", currentElementValue,[currentElementValue length] ); }

    Read the article

  • JSONP parsing error from WCF

    - by user1754730
    Answered my own question I had a problem with a jquery (jsonp) call to a WCF service that was throwing a json parsing error. Using ASP.NET 4.0 on the WCF side and jquery 1.7 on the client side. Turned out there was an old set of script tags on the page using language = VBSCRIPT. The browser was interpreting the returned json packet of script as "VBscript" instead of javascript. I placed a set of empty javascript tags at the top of the page and the browser is now interpreting the json as the proper javascript function. Hope this helps someone else. Tom

    Read the article

  • PHP: Parsing of a given form input variable

    - by Jaime Cross
    How would I go about parsing incoming form data where the name changes based on section of site like: <input type="radio" name="Motorola section" value="Ask a question"> where 'Motorola section may be that, or Verizon section, or Blackberry section, etc. I do not have any control over changing the existing forms unfortunately, so must find a way to work with what is there. Basically, I need to be able to grab both the name="" data as well as its coresponding value="" data to be able to populate the email that gets sent properly.

    Read the article

  • RFC822 Timezone Parsing in Java

    - by Jamen
    Hi, I have a JS date that is being converted by Dojo into RFC822 format. The function call - dojo.date.toRfc3339(jsDate), generates the following date - 2007-02-26T20:15:00+02:00. I have an application that uses a Java date SimpleDateFormat to parse in the dates generated above. I am having problems parsing this date format due to the timezone. I have attempted to use yyyy-mm-DD'T'hh:mm:ssZ This fails as the 'Z' for timezone doesn't expect a ':' character. Does anyone know how I would specify a pattern to handle a RFC822 date with the ':'? Thanks Jamen

    Read the article

  • actionscript find and convert text to url

    - by gravesit
    I have this script that grabs a twitter feed and displays in a little widget. What I want to do is look at the text for a url and convert that url to a link. public class Main extends MovieClip { private var twitterXML:XML; // This holds the xml data public function Main() { // This is Untold Entertainment's Twitter id. Did you grab yours? var myTwitterID= "username"; // Fire the loadTwitterXML method, passing it the url to your Twitter info: loadTwitterXML("http://twitter.com/statuses/user_timeline/" + myTwitterID + ".xml"); } private function loadTwitterXML(URL:String):void { var urlLoader:URLLoader = new URLLoader(); // When all the junk has been pulled in from the url, we'll fire finishedLoadingXML: urlLoader.addEventListener(Event.COMPLETE, finishLoadingXML); urlLoader.load(new URLRequest(URL)); } private function finishLoadingXML(e:Event = null):void { // All the junk has been pulled in from the xml! Hooray! // Remove the eventListener as a bit of housecleaning: e.target.removeEventListener(Event.COMPLETE, finishLoadingXML); // Populate the xml object with the xml data: twitterXML = new XML(e.target.data); showTwitterStatus(); } private function addTextToField(text:String,field:TextField):void{ /*Regular expressions for replacement, g: replace all, i: no lower/upper case difference Finds all strings starting with "http://", followed by any number of characters niether space nor new line.*/ var reg:RegExp=/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig; //Replaces Note: "$&" stands for the replaced string. text.replace(reg,"<a href=\"$&\">$&</a>"); field.htmlText=text; } private function showTwitterStatus():void { // Uncomment this line if you want to see all the fun stuff Twitter sends you: //trace(twitterXML); // Prep the text field to hold our latest Twitter update: twitter_txt.wordWrap = true; twitter_txt.autoSize = TextFieldAutoSize.LEFT; // Populate the text field with the first element in the status.text nodes: addTextToField(twitterXML.status.text[0], twitter_txt); }

    Read the article

  • Retrieving the first picture with a HTML parser

    - by justin01
    Hey guys, (Not a native english speaker) I'm doing a personal project in PHP in which I use the Simple HTML Parser to parse the HTML of a given URL and retrieve the first image in a DIV that have a specific ID or class (maincontent, content, main, wrapper, etc. - it's all in an array) and ignore ads. The goal is to take this image and make a thumbnail with it, pretty much like on Digg and others. I thought everything was working fine until I tried my script with the website Snopes ("http://www.snopes.com/photos/animals/luckycoyote.asp" <- this page more exactly). The source of the first image it gets is: " graphics/luckycoyote1.jpg ". So far, to correct this problem I created a little function that gets the domain name of the given URL and insert it before the IMG's source attribute. So for sites like Snopes.com, it gives me: "http://www.snopes.com/graphics/luckycoyote1.jpg" ... while the real URL for this image is "http://www.snopes.com*/photos/animals/graphics/luckycoyote1.jpg*" (or, more precisely: " http://graphics1.snopes.com/photos/animals/graphics/luckycoyote1.jpg " - note the subdomain here). So my main question is: how can I externally/dynamically retrieve the full URL address of an image ("absolute path") when I am only given the "relative path"? I'm pretty sure this is possible, since when I paste the link in Facebook's "What are you doing?" field for example, it gives me the correct path to the image while on the website, the source of the image is only (example) "image/photo/example.jpg". Thank you for your time.

    Read the article

  • DocumentBuilder.parse() / Parsing Entities

    - by stormin986
    I'm new to parsing XML and am having an issue with entities. (Am doing this on Android, if it makes a difference). Is there a way to have it turn an entity into the character it represents? I have this in the child of an element: "isn&#39;t" (minus quotes). I would prefer it parse it and the end result be a single text node. However, right now this is turned in to TEXT, ENTITY, TEXT. Is there a way to automatically have it parse the entity into text, or a manual way to do it?

    Read the article

  • (Python) Extracting Text from Source Code?

    - by zhuyxn
    Currently have a large webpage whose source code is ~200,000 lines of almost all (if not all) HTML. More specifically, it is a webpage whose content is a few thousand blocks of paragraphs separated by line breaks (though a line break does not specifically mean there is a separation in content) My main objective is to extract text from the source code as if I were copying/pasting the webpage into a text editor. There is another parsing function I would like to use, which originally took in copied/pasted text rather than the source code. To do this, I'm currently using urllib2, and calling .get_text() in Beautiful Soup. The problem is, Beautiful Soup is leaving tremendous amounts of white space in my code, and it is difficult to pass the result into the second "text" parser. I have done quite a bit of research on parsing HTMLs, but I'm frankly not sure how to solve this problem easily. Furthermore, I'm a bit confused on how to use imports like lxml to extract text as if I were to simply copy and paste?

    Read the article

  • Action Cache for root URL not working

    - by askegg
    Here's the setup. I have web site which is essentially a simple CMS. Here is the routes file: map.connect ':url', :controller => :pages, :action => :show map.root :controller => :pages, :action => :show, :url => "/" The page controller is thus: class PagesController < ApplicationController before_filter :verify_access, :except => [:show] # Cache show action if we are not logged in. caches_action :show, :layout => false, :unless => Proc.new { |controller| controller.logged_in? } def update @page = Page.find(params[:id]) respond_to do |format| expire_action :action => :show, :url => @page.url So when a visitor hits "/" it maps to :controller = "pages, :action = "show, :url = "/". This generates a cached version on first try, then returns the appropriate result there after. The log files show: Processing PagesController#show (for 127.0.0.1 at 2009-08-02 14:15:01) [GET] Parameters: {"action"=>"show", "url"=>"/", "controller"=>"pages"} Cached fragment hit: views/out.local// (0.1ms) Rendering template within layouts/application Filter chain halted as [#<ActionController::Filters::AroundFilter:0x23eb03c @identifier=nil, @method=#<Proc:0x01904858@/Library/Ruby/Gems/1.8/gems/actionpack-2.3.3/lib/action_controller/caching/actions.rb:64>, @kind=:filter, @options={:only=>#<Set: {"show"}>, :if=>nil, :unless=>#<Proc:0x025137ac@/Users/askegg/Sites/out/app/controllers/pages_controller.rb:6>}>] did_not_yield. Completed in 2ms (View: 1, DB: 0) | 200 OK [http://out.local/] OK - all good so far. When I update the page, it should expire the cache (see above). The logs show: Page Load (0.2ms) SELECT * FROM "pages" WHERE ("pages"."id" = 3) Page Load (0.1ms) SELECT "pages".id FROM "pages" WHERE ("pages"."url" = '/' AND "pages".domain_id = 1 AND "pages".id <> 3) LIMIT 1 Expired fragment: views/out.local/index (0.1ms) Redirected to http://out.local/pages/3 Completed in 9ms (DB: 0) | 302 Found [http://out.local/pages/3] See the problem? Rails is clearing the cache named "index", but it sets it as "/". Naturally this results in the cache NOT being cleared, so visitors are now seeing the old version.

    Read the article

  • IIS7 URL Redirect with Regex

    - by andyjv
    I'm preparing for a major overhaul of our shopping cart, which is going to completely change how the urls are structured. For what its worth, this is for Magento 1.7. An example URL would be: {domain}/item/sub-domain/sub-sub-domain-5-16-7-16-/8083770?plpver=98&categid=1027&prodid=8090&origin=keyword and redirect it to {domain}/catalogsearch/result/?q=8083710 My web.config is: <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="Magento Required" stopProcessing="false"> <match url=".*" ignoreCase="false" /> <conditions> <add input="{URL}" pattern="^/(media|skin|js)/" ignoreCase="false" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> </conditions> <action type="Rewrite" url="index.php" /> </rule> <rule name="Item Redirect" stopProcessing="true"> <match url="^item/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)/([_\-a-zA-Z0-9]+)(\?.*)" /> <action type="Redirect" url="catalogsearch/result/?q={R:3}" appendQueryString="true" redirectType="Permanent" /> <conditions trackAllCaptures="true"> </conditions> </rule> </rules> </rewrite> <httpProtocol allowKeepAlive="false" /> <caching enabled="false" /> <urlCompression doDynamicCompression="true" /> </system.webServer> </configuration> Right now it seems the redirect is completely ignored, even though in the IIS GUI the sample url passes the regex test. Is there a better way to redirect or is there something wrong with my web.config?

    Read the article

  • IIS 7.5, Multiple Application Pools, and URL Rewriting (403.18 -- Forbidden)

    - by Jerry Hewett
    Is there any way to configure IIS 7.5 to perform URL rewrites to different application pools on the same site without running into a 403.18 error? We're using Helicon ISAPI Rewrite 3 on IIS 6 and it's working like a charm. The root-level "application" is running under it's own application pool, and on IIS 6 we have no problems doing URL rewrites from that application pool to any one of the other four application pools. But when I copy the same server configuration information over to IIS 7.5 the URL rewrites to any of the other application pools fail with a "403.18 -- Forbidden" error. The weird bit is that the IIS 6 is not (at least as far as I can tell, by looking at the site Service configuration dialog) running under IIS 5 emulation mode, so somehow the rewrites aren't throwing 403.18 errors. So something must be different... but whatever it is, I sure haven't been able to figure it out. Btw, we're not married to Helicon ISAPI Rewrite. If there's another way to preserve our current rewrite configuration rules using another module or method I'd be more than happy to use it.

    Read the article

  • IIS 7.5, Multiple Application Pools, and URL Rewriting (403.18 -- Forbidden)

    - by Jerry Hewett
    Is there any way to configure IIS 7.5 to perform URL rewrites to different application pools on the same site without running into a 403.18 error? We're using Helicon ISAPI Rewrite 3 on IIS 6 and it's working like a charm. The root-level "application" is running under it's own application pool, and on IIS 6 we have no problems doing URL rewrites from that application pool to any one of the other four application pools. But when I copy the same server configuration information over to IIS 7.5 the URL rewrites to any of the other application pools fail with a "403.18 -- Forbidden" error. The weird bit is that the IIS 6 is not (at least as far as I can tell, by looking at the site Service configuration dialog) running under IIS 5 emulation mode, so somehow the rewrites aren't throwing 403.18 errors. So something must be different... but whatever it is, I sure haven't been able to figure it out. Btw, we're not married to Helicon ISAPI Rewrite. If there's another way to preserve our current rewrite configuration rules using another module or method I'd be more than happy to use it.

    Read the article

< Previous Page | 68 69 70 71 72 73 74 75 76 77 78 79  | Next Page >