Ejemplo n.º 1
0
def get(arg, host):
	try:
		split = SPLIT.match(arg)
		head = split.group('head')
		pre = split.group('pre')
		post = split.group('post')	

		#print "Head: \033[32m\033[1m" + head + "\033[0m\033[0m\n\n"
		#print "Pre: \033[32m\033[1m" + pre + "\033[0m\033[0m\n\n"
		#print "Post: \033[32m\033[1m" + post + "\033[0m\033[0m\n\n"
		
		print "Inserted"
		#mod.write(head + scripts.get("this")  + pre + banner.get("this") + popup.get(body) + post)
		if "amazon" in host:
			return head + scripts.get(arg) + pre + banner.get(arg) + popup.get(arg) + post
		else:
			return head + scripts.get(arg) + pre + banner.get(arg) + post
	except:
		print "\033[32m\033[1m" + "didn't work" + "\033[0m\033[0m\n\n"
		#print arg
		return arg
Ejemplo n.º 2
0
#!/usr/bin/python


import os
import re
import banner, footer, amazon, popup

INSERT_AD = re.compile ('(?P<pre>.*<\s*HTML[^<]*>)(?P<post>.*)', re.IGNORECASE | re.MULTILINE | re.DOTALL)

#body = "<body><h1 class='parseasinTitle '><span id='btAsinTitle'  >Wondfo Pregnancy Test Strips, 25-count</span></body>"

with open ("input.html", "r") as myfile:
    body=myfile.read().replace('\n', '')

tmp = INSERT_AD.match(body)

print tmp

pre = tmp.group('pre')
post = tmp.group('post')

original = open("original.html", "w")
mod = open("mod.html", "w")

original.write(pre + post)
mod.write( pre + banner.get("this")  + popup.get(body) + footer.get("this") + post)

amazon.get(body)