PDA

View Full Version : کد برای نوشتن خزنده ی وب در پایتون



fateme_abdi
پنج شنبه 29 مهر 1395, 20:55 عصر
سلام من دارم یه فیلم آموزشی می بینم که برای نوشتن خزنده ی وب هستش برنامه نویسی ک آموزش میده با لینوکس کار میکنه ولی من تو ویندوز کار می کنم:



from _symtable import DEF_IMPORT
from setuptools.command.develop import develop
from email.header import UTF8
from lxml import html
import requests
import time


class AppCrawler:


def __init__(self, starting_url, depth):
self.starting_url = starting_url
self.depth = depth
self.apps = []


def crawl(self):
self.get_app_from_link(self.starting_url)
return

def get_app_from_link(self, link):
start_page = requests.get(link)

print start_page
return






class App:


def __init__(self, name, developer, price, links):
self.name = name
self.developer = developer
self.price = price
self.links = links


def __str__(self):
return ("Name: " + self.name.encode('UTF-8') +
"\r\nDeveloper: " + self.developer.encode('UTF-8') +
"\r\nPrice: " + self.price.encode('UTF-8') + "\r\n")




crawler = AppCrawler('https://itunes.apple.com/us/app/candy-crush-saga/id553834731', 0)
crawler.crawl()


for app in crawler.apps:
print app





حالا برای اون برنامه نویس درست اجرا میشه برای من این ارورها میاد:
n27\lib\requests\packages\urllib3\util\ssl_.py:318 : SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
SNIMissingWarning
C:\Python27\lib\requests\packages\urllib3\util\ssl _.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning

Felony
دوشنبه 03 آبان 1395, 09:18 صبح
کتابخانه های SSL بسته به نسخه خودشون و نسخه verification cert ها مشکلات این چنینی دارن ، اینجا رو بخونین :

http://stackoverflow.com/questions/29099404/ssl-insecureplatform-error-when-using-requests-package
http://stackoverflow.com/questions/29134512/insecureplatformwarning-a-true-sslcontext-object-is-not-available-this-prevent

fateme_abdi
چهارشنبه 05 آبان 1395, 09:10 صبح
خب خودم جوابش رو فهمیدم می نویسم که اگه کسی این سوال رو داشت بدونه:
باید تو cmd در حالی که به نت کانکتید بنویسید:
[pip install requests[security
البته اولش باید خود pip نصب باشه تو سیستمتون برای همون ورژن پایتونی ک دارید
اگه احیانا این دستور رو زدید ولی گفت pip رو نمیشناسه قبل همین عبارت ادرسش رو بنویسید مثلا مال من این آدرسشه:
[c:\pytho27\scripts\pip install requests[security