Answer the question
In order to leave comments, you need to log in
Python. How to check if the result contains a word?
Good afternoon.
There is the following code:
import requesocks
from stem import Signal
from stem.control import Controller
from bs4 import BeautifulSoup
from urllib2 import urlopen
def change_proxy():
with Controller.from_port(port = 9151) as controller:
controller.authenticate(password="password")
controller.signal(Signal.NEWNYM)
session = requesocks.session()
session.proxies = {'http': 'socks5://127.0.0.1:9150',
'https': 'socks5://127.0.0.1:9150'}
link = "https://www.reformagkh.ru/myhouse/profile/view/7698523/"
res = session.get(link).text
soup = BeautifulSoup(''.join(res), 'html.parser')
if 'center' in soup.findAll('script')[14]:
print "1"
else:
print "2"
change_proxy()
<script type="text/javascript">
window.onload = function () {
var mapConfig = {
center: [48.720853,44.473506],
zoom: 14
};
ymaps.ready(function () {
var rgkhMap = new ymaps.Map('map', mapConfig),
balloonContentBody = "\u043e\u0431\u043b. \u0412\u043e\u043b\u0433\u043e\u0433\u0440\u0430\u0434\u0441\u043a\u0430\u044f, \u0433. \u0412\u043e\u043b\u0433\u043e\u0433\u0440\u0430\u0434",
balloonContentHeader = "\u0410\u043d\u0433\u0430\u0440\u0441\u043a\u0430\u044f, 59, \u0441\u043e\u043e\u0440\u0443\u0436\u0435\u043d\u0438\u0435 ",
balloonContent = '<h3>' + balloonContentHeader + '</h3><p>' + balloonContentBody + '</p>';
rgkhMap.controls.remove('mapTools')
.remove('geolocationControl')
.remove('searchControl')
.remove('trafficControl')
.remove('rulerControl');
var myPlacemark = new ymaps.Placemark(
[48.720853,44.473506],
{balloonContent: balloonContent}
);
rgkhMap.geoObjects.add(myPlacemark);
});
}
</script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question