How to print the full source code of URL? - in this particular case it prints only fractionFast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?NSXMLParserErrorDomain 111How To Get HTML source from URL with SwiftText gets truncated when converted from NSString to Swift StringFirebase storage image url not workingHow to know if a string is already escaped special with special characters?Cannot convert value of type '(User?, _) -> ()' to expected argument type.i am struggling to resolve that errorError handling for URLSession.shared.datataskLoading images from a URL and storing them locally using Swift4Cancelling a view controller from loading if a URL cannot load - Swift 4

Copying an existing HTML page and use it, is that against any copyright law?

Does Wolfram Mathworld make a mistake describing a discrete probability distribution with a probability density function?

Why did House of Representatives need to condemn Trumps Tweets?

What are the cons of stateless password generators?

Does Dispel Magic destroy Artificer Turrets?

What is more environmentally friendly? An A320 or a car?

If an arcane trickster rogue uses his mage hand and makes it invisible, does that mean anything the hand picks up is also invisible?

Incrementing add under condition in pandas

Why do they sell Cat 5 Ethernet splitters if you can’t split the signal?

Is there a wealth gap in Boston where the median net worth of white households is $247,500 while the median net worth for black families was $8?

Should I bike or drive to work? (6.8 mi)

Why does this RX-X lock not appear in Extended Events?

What is "sed -i 's,-m64,,g'" doing to this Makefile?

Why is it considered acid rain with pH <5.6?

Why did Windows 95 crash the whole system but newer Windows only crashed programs?

Golden Guardian removed before death related trigger

Does dual boot harm a laptop battery or reduce its life?

Dual-national, returning to US the day the US Passport expires; can he check in with airline on Dutch passport but reenter with expiring US passport?

If Trump gets impeached, how long would Pence be president?

Is there an antonym for "spicy" or "hot" regarding food?

Did the Americans trade destroyers in the "destroyer deal" that they would later need themselves?

What language is Raven using for her attack in the new 52?

Dobbs Murder Mystery : A Picture worth 1000 words?

Is it okay for me to decline a project on ethical grounds?



How to print the full source code of URL? - in this particular case it prints only fraction


Fast and Lean PDF Viewer for iPhone / iPad / iOs - tips and hints?NSXMLParserErrorDomain 111How To Get HTML source from URL with SwiftText gets truncated when converted from NSString to Swift StringFirebase storage image url not workingHow to know if a string is already escaped special with special characters?Cannot convert value of type '(User?, _) -> ()' to expected argument type.i am struggling to resolve that errorError handling for URLSession.shared.datataskLoading images from a URL and storing them locally using Swift4Cancelling a view controller from loading if a URL cannot load - Swift 4






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















I have already retrieved source codes from some sites for my app and have used the function:



let usedURLString = "my http link"



guard let usedURL = URL(string: usedURLString) else
// if URL is not valid:
print("Error: (usedURLString) doesn't seem to be a valid URL")
return
do
// getting the HTML sourcecode

let sourceCodeHTML = try String(contentsOf: usedURL, encoding: String.Encoding.windowsCP1254)

print(sourceCodeHTML)
catch
print("there was an error: (error)")



Now I am struggling with the problem that I can't retrieve the full source code from a site that says it needs "This page needs javascript to run". When using the function above it prints only a small and weird fraction of html string. Can anyone help me with the issue? I have searched in many places but haven't found any solution to the issue.










share|improve this question



















  • 4





    Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

    – matt
    Mar 26 at 19:48











  • Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

    – Yaming Lin
    Mar 26 at 20:09












  • I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

    – Timothy Stokarski
    Mar 26 at 21:00












  • I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

    – Yaming Lin
    Mar 27 at 1:57











  • There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

    – Timothy Stokarski
    Mar 27 at 9:26

















-1















I have already retrieved source codes from some sites for my app and have used the function:



let usedURLString = "my http link"



guard let usedURL = URL(string: usedURLString) else
// if URL is not valid:
print("Error: (usedURLString) doesn't seem to be a valid URL")
return
do
// getting the HTML sourcecode

let sourceCodeHTML = try String(contentsOf: usedURL, encoding: String.Encoding.windowsCP1254)

print(sourceCodeHTML)
catch
print("there was an error: (error)")



Now I am struggling with the problem that I can't retrieve the full source code from a site that says it needs "This page needs javascript to run". When using the function above it prints only a small and weird fraction of html string. Can anyone help me with the issue? I have searched in many places but haven't found any solution to the issue.










share|improve this question



















  • 4





    Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

    – matt
    Mar 26 at 19:48











  • Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

    – Yaming Lin
    Mar 26 at 20:09












  • I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

    – Timothy Stokarski
    Mar 26 at 21:00












  • I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

    – Yaming Lin
    Mar 27 at 1:57











  • There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

    – Timothy Stokarski
    Mar 27 at 9:26













-1












-1








-1








I have already retrieved source codes from some sites for my app and have used the function:



let usedURLString = "my http link"



guard let usedURL = URL(string: usedURLString) else
// if URL is not valid:
print("Error: (usedURLString) doesn't seem to be a valid URL")
return
do
// getting the HTML sourcecode

let sourceCodeHTML = try String(contentsOf: usedURL, encoding: String.Encoding.windowsCP1254)

print(sourceCodeHTML)
catch
print("there was an error: (error)")



Now I am struggling with the problem that I can't retrieve the full source code from a site that says it needs "This page needs javascript to run". When using the function above it prints only a small and weird fraction of html string. Can anyone help me with the issue? I have searched in many places but haven't found any solution to the issue.










share|improve this question














I have already retrieved source codes from some sites for my app and have used the function:



let usedURLString = "my http link"



guard let usedURL = URL(string: usedURLString) else
// if URL is not valid:
print("Error: (usedURLString) doesn't seem to be a valid URL")
return
do
// getting the HTML sourcecode

let sourceCodeHTML = try String(contentsOf: usedURL, encoding: String.Encoding.windowsCP1254)

print(sourceCodeHTML)
catch
print("there was an error: (error)")



Now I am struggling with the problem that I can't retrieve the full source code from a site that says it needs "This page needs javascript to run". When using the function above it prints only a small and weird fraction of html string. Can anyone help me with the issue? I have searched in many places but haven't found any solution to the issue.







ios swift






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 26 at 19:44









Timothy StokarskiTimothy Stokarski

1




1










  • 4





    Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

    – matt
    Mar 26 at 19:48











  • Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

    – Yaming Lin
    Mar 26 at 20:09












  • I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

    – Timothy Stokarski
    Mar 26 at 21:00












  • I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

    – Yaming Lin
    Mar 27 at 1:57











  • There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

    – Timothy Stokarski
    Mar 27 at 9:26












  • 4





    Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

    – matt
    Mar 26 at 19:48











  • Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

    – Yaming Lin
    Mar 26 at 20:09












  • I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

    – Timothy Stokarski
    Mar 26 at 21:00












  • I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

    – Yaming Lin
    Mar 27 at 1:57











  • There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

    – Timothy Stokarski
    Mar 27 at 9:26







4




4





Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

– matt
Mar 26 at 19:48





Well, for one thing, String(contentsOf: usedURL) is absolutely not the correct way to fetch the HTML from a web page. You are networking, use URLSession. That's what it's for.

– matt
Mar 26 at 19:48













Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

– Yaming Lin
Mar 26 at 20:09






Could you please provide the link from which you want to retrieve the source code? I delete encoding: String.Encoding.windowsCP1254 and it works for me to retrieve something. Maybe you could change the String.Encoding type.

– Yaming Lin
Mar 26 at 20:09














I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

– Timothy Stokarski
Mar 26 at 21:00






I have already tried changing the encoding type with no success. here is the link: olx.pl/nieruchomosci/mieszkania/sprzedaz/…

– Timothy Stokarski
Mar 26 at 21:00














I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

– Yaming Lin
Mar 27 at 1:57





I tried your code and it works well for me. I did get the source HTML code. Could you please show your error message?

– Yaming Lin
Mar 27 at 1:57













There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

– Timothy Stokarski
Mar 27 at 9:26





There is no error, yet although the console prints source HTML code it is only a fraction of it. If I open source code via chrome on my computer it shows the full, very long code that I need. That is the whole issue

– Timothy Stokarski
Mar 27 at 9:26












1 Answer
1






active

oldest

votes


















0














Try this:



let usedURLString = "my http link"
if let url = URL(string: usedURLString)
do
let contents = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
print(contents)
catch
// contents could not be loaded

else
// the URL was bad!






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365150%2fhow-to-print-the-full-source-code-of-url-in-this-particular-case-it-prints-on%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Try this:



    let usedURLString = "my http link"
    if let url = URL(string: usedURLString)
    do
    let contents = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
    print(contents)
    catch
    // contents could not be loaded

    else
    // the URL was bad!






    share|improve this answer





























      0














      Try this:



      let usedURLString = "my http link"
      if let url = URL(string: usedURLString)
      do
      let contents = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
      print(contents)
      catch
      // contents could not be loaded

      else
      // the URL was bad!






      share|improve this answer



























        0












        0








        0







        Try this:



        let usedURLString = "my http link"
        if let url = URL(string: usedURLString)
        do
        let contents = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
        print(contents)
        catch
        // contents could not be loaded

        else
        // the URL was bad!






        share|improve this answer













        Try this:



        let usedURLString = "my http link"
        if let url = URL(string: usedURLString)
        do
        let contents = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
        print(contents)
        catch
        // contents could not be loaded

        else
        // the URL was bad!







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 26 at 20:03









        Joshua CleetusJoshua Cleetus

        1861 silver badge9 bronze badges




        1861 silver badge9 bronze badges





















            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.







            Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.



















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365150%2fhow-to-print-the-full-source-code-of-url-in-this-particular-case-it-prints-on%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현