1

Can I load HTML on Ghost.py ,

If I use BeautifulSoup get the HTML code , how to load it on Ghost.py .

I try but not success, :

    from ghost import Ghost()
    from urllib.request import urlopen
    from bs4 import BeautifulSoup

    page = urlopen("http://en.wikipedia.org")
    html = BeautifulSoup(page)
    g = Ghost()
    with g.start() as session:
       page, resources = session.open(html)

Thank you for help .

Er Tong
  • 11
  • 3
  • `session.open("http://en.wikipedia.org")` – Joran Beasley May 11 '16 at 03:04
  • Lol, my bad. Ignore that last comment. Needed a vent. – icedwater May 11 '16 at 03:08
  • Thank you for reply , but if I olny want load to code from BS , do you know how to do it ? – Er Tong May 11 '16 at 03:10
  • There's a number of problems with your code; you shouldn't be importing `Ghost()`, and there's no `request` in `urllib`. Otherwise, using the URL in `session.open` as @JoranBeasley suggests looks like it could be the answer. Then again, I've only got timeouts and segfaults so far... – icedwater May 12 '16 at 02:04
  • I solved this problem : import requests s = requests.session() s.post(URL, data=data, headers=header) r = s.post(URL, data=, headers=header) c_file = open('a.html', 'w') for html in r.text: c_file.write(html) c_file.close() – Er Tong May 17 '16 at 02:19

0 Answers0