init commit

This commit is contained in:
Anna Sudnitsina 2018-06-19 17:15:50 +03:00
commit 3abb4a612a
6 changed files with 724 additions and 0 deletions

View File

@ -0,0 +1,15 @@
{
"id": "89021913-6406-465a-9a0c-06db066faf51",
"name": "Inventory API",
"values": [
{
"key": "url",
"value": "http://127.0.0.1:8000",
"enabled": true,
"type": "text"
}
],
"_postman_variable_scope": "environment",
"_postman_exported_at": "2018-06-13T09:17:38.039Z",
"_postman_exported_using": "Postman/6.1.3"
}

BIN
chromedriver.exe Normal file

Binary file not shown.

6
debug.log Normal file
View File

@ -0,0 +1,6 @@
[0619/143311.631:ERROR:process_reader_win.cc(123)] NtOpenThread: {Отказано в доступе} Процесс запросил доступ к объекту, но права на доступ не предоставлены. (0xc0000022)
[0619/143311.635:ERROR:exception_snapshot_win.cc(88)] thread ID 12664 not found in process
[0619/164929.666:ERROR:process_reader_win.cc(123)] NtOpenThread: {Отказано в доступе} Процесс запросил доступ к объекту, но права на доступ не предоставлены. (0xc0000022)
[0619/164929.667:ERROR:exception_snapshot_win.cc(88)] thread ID 15452 not found in process
[0619/170248.816:ERROR:process_reader_win.cc(123)] NtOpenThread: {Отказано в доступе} Процесс запросил доступ к объекту, но права на доступ не предоставлены. (0xc0000022)
[0619/170248.817:ERROR:exception_snapshot_win.cc(88)] thread ID 11200 not found in process

View File

@ -0,0 +1,629 @@
{
"info": {
"_postman_id": "bc2a9f01-c583-47e6-b911-69f399bd30a4",
"name": "inventory",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
},
"item": [
{
"name": "create inventory",
"event": [
{
"listen": "test",
"script": {
"id": "661c9fbf-3f52-4256-9220-8d32cbfda581",
"type": "text/javascript",
"exec": [
"//postman.clearEnvironmentVariable(\"inv\");",
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"tests[\"status code is 200\"] == responseCode.code === 200;"
]
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv"
]
}
},
"response": []
},
{
"name": "inventory",
"event": [
{
"listen": "test",
"script": {
"id": "3f46c773-6962-484e-9029-66487ceb1eff",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"",
"var jsonData = JSON.parse(responseBody);",
"tests['json'] = jsonData == \"my_inv\";",
"",
"tests[\"inv good\"] = responseBody == '[\"my_inv\"]';",
"tests[\"content type\"] = postman.getResponseHeader('Content-Type') === 'application/json';",
"",
"postman.setEnvironmentVariable(\"inv\", jsonData);",
"tests[\"Body is object\"] = typeof jsonData == \"object\";"
]
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "{{url}}/api/inventories",
"host": [
"{{url}}"
],
"path": [
"api",
"inventories"
]
}
},
"response": []
},
{
"name": "group create",
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/{{inv}}/groups/first_group",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"{{inv}}",
"groups",
"first_group"
]
}
},
"response": []
},
{
"name": "group create child",
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/my_child",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"my_child"
]
}
},
"response": []
},
{
"name": "groups",
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "{{url}}/api/inventory/my_inv/groups/",
"host": [
"{{url}}"
],
"path": [
"api",
"inventory",
"my_inv",
"groups",
""
]
}
},
"response": []
},
{
"name": "vars",
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/vars",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"vars"
]
}
},
"response": []
},
{
"name": "vars create",
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/vars/my_var",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"vars",
"my_var"
]
}
},
"response": []
},
{
"name": "children",
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/children",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"children"
]
}
},
"response": []
},
{
"name": "children create",
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/children/my_child",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"children",
"my_child"
]
}
},
"response": []
},
{
"name": "hosts",
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/hosts",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"hosts"
]
}
},
"response": []
},
{
"name": "hosts create",
"event": [
{
"listen": "test",
"script": {
"id": "040fd106-e290-4c49-86ee-fb1dd3c24dfd",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"",
"tests[\"response\"] = responseBody.has(\"detail\");",
"",
"var jsonData = JSON.parse(responseBody);",
"tests['json'] = jsonData[\"detail\"] == \"Not found.\";"
]
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/hosts/my_host",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"hosts",
"my_host"
]
}
},
"response": []
},
{
"name": "machine create",
"event": [
{
"listen": "test",
"script": {
"id": "6c3f2287-161c-42b3-9280-c10cfd2aa9af",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"",
"var jsonData = JSON.parse(responseBody);",
"tests['json'] = jsonData[\"status\"] == \"ADD\"; jsonData[\"details\"] == \"machine\"; "
]
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/machines/my_machine",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"machines",
"my_machine"
]
}
},
"response": []
},
{
"name": "machine delete",
"event": [
{
"listen": "test",
"script": {
"id": "05ae09d7-d687-4027-a6aa-c906a0889242",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"",
"var jsonData = JSON.parse(responseBody);",
"tests['response'] = jsonData[\"status\"] == \"delete\"; jsonData[\"details\"] == \"machine\"; ",
"",
""
]
}
}
],
"request": {
"method": "DELETE",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "{{url}}/api/machines/my_machine",
"host": [
"{{url}}"
],
"path": [
"api",
"machines",
"my_machine"
]
}
},
"response": []
},
{
"name": "hosts create successfully",
"event": [
{
"listen": "test",
"script": {
"id": "c73220fb-c363-4672-bb25-2d171c4f204f",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"",
"var jsonData = JSON.parse(responseBody);",
"tests['json'] = jsonData[\"status\"] == \"ADD\"; jsonData[\"details\"] == \"host\"; "
]
}
}
],
"request": {
"method": "PUT",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv/groups/first_group/hosts/my_machine",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv",
"groups",
"first_group",
"hosts",
"my_machine"
]
}
},
"response": []
},
{
"name": "get inventory json",
"event": [
{
"listen": "test",
"script": {
"id": "80ef89ad-c979-4fdf-941a-ae9bce482c44",
"type": "text/javascript",
"exec": [
"tests[\"Response time is less than 200ms\"] = responseTime < 200;",
"tests[\"status code is 200\"] == responseCode.code === 200;",
"var jsonData = JSON.parse(responseBody);",
"tests[\"Response contains 'all'\"] = responseBody.has(\"all\");"
]
}
}
],
"request": {
"method": "GET",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "{{url}}/api/inventory/my_inv",
"host": [
"{{url}}"
],
"path": [
"api",
"inventory",
"my_inv"
]
}
},
"response": []
},
{
"name": "delete inventory",
"event": [
{
"listen": "test",
"script": {
"id": "4acda595-ed90-4b19-85ec-c22c74296bc1",
"type": "text/javascript",
"exec": [
"postman.clearEnvironmentVariable(\"inv\");",
"",
"tests[\"status code is 200\"] == responseCode.code === 200;",
"var jsonData = JSON.parse(responseBody);",
"tests['json'] = jsonData[\"status\"] == \"DELETE\"; jsonData[\"details\"] == \"inventory\";"
]
}
}
],
"request": {
"method": "DELETE",
"header": [
{
"key": "X-Auth-Token",
"value": "c7ddde9d507837a770161779f8debdab91e70344731a0bd148741d98c94d9691"
}
],
"body": {},
"url": {
"raw": "http://127.0.0.1:8000/api/inventory/my_inv",
"protocol": "http",
"host": [
"127",
"0",
"0",
"1"
],
"port": "8000",
"path": [
"api",
"inventory",
"my_inv"
]
}
},
"response": []
}
]
}

21
smule_parser.py Normal file
View File

@ -0,0 +1,21 @@
import requests
from BeautifulSoup import BeautifulSoup
from selenium import webdriver
url = 'https://www.smule.com/sudnitsina/followers'
res = requests.get(url)
soup = BeautifulSoup(res.content.decode('utf-8'))
followers = [i.contents[0] for i in soup.find('div', 'profile-content-block').findAll('a')]
url = 'https://www.smule.com/sudnitsina/following'
res = requests.get(url)
soup = BeautifulSoup(res.content.decode('utf-8'))
following = [i.contents[0] for i in soup.find('div', 'profile-content-block').findAll('a')]
my_list = list(filter(lambda x: x not in followers, following))
driver = webdriver.Chrome()
for i in my_list:
driver.get("https://www.smule.com/"+i)
raw_input(i)
#print my_list

53
twitter_cleaner.py Normal file
View File

@ -0,0 +1,53 @@
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
import random
url = 'https://twitter.com/following'
driver = webdriver.Chrome()
driver.maximize_window()
driver.get(url)
LOGIN = "salix666@mail.ru"
PASS = "pupsi4ek314"
username_locator = "#page-container > div > div.signin-wrapper > form > fieldset > div:nth-child(2) > input"
driver.find_element_by_css_selector(username_locator).send_keys(LOGIN)
password_locator = "#page-container > div > div.signin-wrapper > form > fieldset > div:nth-child(3) > input"
driver.find_element_by_css_selector(password_locator).send_keys(PASS, Keys.RETURN)
# e = driver.find_element_by_xpath('//*[@id="page-container"]/div/div[1]/form/fieldset/div[2]/input')
tel_num = '+375447190445'
tel = '// *[ @ id = "challenge_response"]'
driver.find_element_by_xpath(tel).send_keys(tel_num, Keys.RETURN)
#following_selector = "#stream-item-user-476338341 > div > div > div.ProfileCard-userFields > div > div > a"
#e = driver.find_element_by_css_selector(following_selector).click()
# chitayu = "div > div > div.ProfileCard-actions > div > div > div > span.user-actions-follow-button.js-follow-btn.follow-button > button.EdgeButton.EdgeButton--primary.EdgeButton--small.button-text.following-text > span:nth-child(1)"
chitayu = "//div/div/div[1]/div/div/div/span[2]/button[2]"
count = 0
while count < 150:
# e = driver.find_elements_by_css_selector(chitayu)
e = driver.find_elements_by_xpath(chitayu)
e = [i for i in e if i.is_displayed()]
print len(e)
for i in e:
i.click()
count += 1
time.sleep(float(random.randint(10000, 15000))/10000)
# unretweet = "div.tweet.js-stream-tweet.js-actionable-tweet.js-profile-popup-actionable.dismissible-content.original-tweet.js-original-tweet.tweet-has-context.retweeted > div.content > div.stream-item-footer > div.ProfileTweet-actionList.js-actions > div.ProfileTweet-action.ProfileTweet-action--retweet.js-toggleState.js-toggleRt > button.ProfileTweet-actionButtonUndo.js-actionButton.js-actionRetweet.following-text"
# e = driver.find_elements_by_css_selector(unretweet)
# e = driver.find_element_by_xpath(unretweet)
#
# for i in e[:19]:
# i.click()
# time.sleep(float(random.randint(10000, 15000))/10000)
#coolies = [{u'domain': u'.twitter.com', u'secure': True, u'value': u'abf472f4a3bcb4cfd76e22479a5dd84d', u'expiry': 1529437783.704496, u'path': u'/', u'httpOnly': False, u'name': u'ct0'}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'v1%3A152941619670488003', u'expiry': 1592488184.451045, u'path': u'/', u'httpOnly': False, u'name': u'guest_id'}, {u'domain': u'twitter.com', u'name': u'lang', u'value': u'ru', u'path': u'/', u'httpOnly': False, u'secure': False}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'"v1_5jVdNIuOjm9ZO1QrV6eORA=="', u'expiry': 1592488184.450999, u'path': u'/', u'httpOnly': False, u'name': u'personalization_id'}, {u'domain': u'.twitter.com', u'secure': True, u'value': u'"u=383335682"', u'expiry': 1844776192.500618, u'path': u'/', u'httpOnly': False, u'name': u'twid'}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'GA1.2.1973448638.1529416189', u'expiry': 1529502595, u'path': u'/', u'httpOnly': False, u'name': u'_gid'}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'GA1.2.1387155670.1529416189', u'expiry': 1592488195, u'path': u'/', u'httpOnly': False, u'name': u'_ga'}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'"HBERAAA="', u'expiry': 1844776192.500327, u'path': u'/', u'httpOnly': False, u'name': u'ads_prefs'}, {u'domain': u'.twitter.com', u'secure': True, u'value': u'4ReWgwFoZz2Kv092u7vxDUM1OjA6UZUOffb3SrSE', u'expiry': 1576676992.5004, u'path': u'/', u'httpOnly': True, u'name': u'kdt'}, {u'domain': u'.twitter.com', u'secure': False, u'value': u'1', u'expiry': 1844776192.500469, u'path': u'/', u'httpOnly': False, u'name': u'remember_checked_on'}, {u'domain': u'.twitter.com', u'name': u'_twitter_sess', u'value': u'BAh7DCIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNo%250ASGFzaHsABjoKQHVzZWR7ADoPY3JlYXRlZF9hdGwrCGMiTxhkAToHaWQiJTQ5%250AZDVhZTEwMDM5YjFhMzYwM2FjNDg1OWYxZjViMDFhOgxjc3JmX2lkIiU0YjQx%250ANDY3MzRlNzcwYzI5NDk0NDRjMGMwMmQ0MjcwYjofbG9naW5fdmVyaWZpY2F0%250AaW9uX3VzZXJfaWRpBAI92RY6ImxvZ2luX3ZlcmlmaWNhdGlvbl9yZXF1ZXN0%250AX2lkIiU2aVBYaGtWQWxaZktteURUa1k2aE16eldSWGZNY0NhNToJdXNlcmkE%250AAj3ZFg%253D%253D--c557a83f88438f871b368a12705946bd2898da4d', u'path': u'/', u'httpOnly': True, u'secure': True}, {u'domain': u'.twitter.com', u'secure': True, u'value': u'8804b166eaad2d865c19f400f9c9c41c0981db92', u'expiry': 1844776192.50068, u'path': u'/', u'httpOnly': True, u'name': u'auth_token'}, {u'domain': u'.twitter.com', u'secure': True, u'value': u'1', u'expiry': 1560865793.096713, u'path': u'/', u'httpOnly': True, u'name': u'csrf_same_site_set'}, {u'domain': u'.twitter.com', u'secure': True, u'value': u'1', u'expiry': 1560952193.096874, u'path': u'/', u'httpOnly': True, u'name': u'csrf_same_site'}]
#for i in cookies:
# driver.add_cookie(i)